Scheduling method and device of parallel program and storage medium
By monitoring the child process creation behavior of parallel programs, adjusting the scheduling domain hierarchy, and applying affinity tags, the utilization of processor resources was optimized, solving the problem of insufficient resource utilization in NUMA architecture and improving the running efficiency of parallel programs.
Patent Information
- Application Number
- CN202511226424.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-29
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2045-08-29
AI Technical Summary
In NUMA memory architecture, the resource scheduling utilization of parallel programs in existing processor systems is insufficient, especially when short parallel programs are frequently called, resulting in the underutilization of system resources in some time periods. Furthermore, multiple parallel programs may be created on different nodes, affecting running efficiency.
By monitoring the number of child processes created by a process, assigning pre-designed values, and adjusting the scheduling domain level within a preset period, child processes are created in higher-level scheduling domains. Combined with affinity flags and core queue idle judgment, the allocation of child processes is optimized.
It improves the utilization of processor resources, reduces process congestion, maintains the interaction efficiency of parallel programs, and achieves more efficient resource utilization.
Smart Images

Figure CN120723420B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application is suitable for the field of processor technology, and particularly relates to a scheduling method and device of parallel program and a storage medium. BACKGROUND
[0002] In current processor systems, for parallel programs such as programs implemented based on OpenMP (Open Multi-Processing, an application programming interface for shared memory parallel programming), due to the processing mode of the scheduler, all sub-processes are created on the current NUMA node and the NUMA node close to it in the commonly used memory architecture such as NUMA (Non-Uniform Memory Access architecture), and the global load balancing is only performed at each scheduling period (tick).
[0003] Such processing is unbalanced in terms of global load in the memory of the parallel program in the first few scheduling periods of the parallel program running. In actual production environment, for long-running parallel programs, these time periods (before scheduling) have little effect on processor resources, but if short parallel programs are frequently called, the system's all central processor resources are not fully utilized in some time periods, which causes certain resource loss.
[0004] On the other hand, when short parallel programs are frequently called, the operating system kernel itself cannot perceive the characteristics of the program architecture, and without human intervention, multiple parallel programs with higher interactivity can also be created in different nodes, which affects their running efficiency. SUMMARY
[0005] The present application provides a scheduling method, device and storage medium of parallel program, aiming at solving the technical problem of insufficient resource scheduling utilization of the existing processor system.
[0006] To solve the above technical problem, in a first aspect, the present application provides a scheduling method of parallel program, which comprises the following steps:
[0007] S101, monitoring the process running in the first-level scheduling domain of the processor system, and when the process is running, assigning a preset value to the process according to the number of sub-processes created by the process in a preset period;
[0008] S102, comparing the preset value with the number of cores in the processor system, wherein:
[0009] If the preset design value is greater than or equal to the number of the cores, a scheduling domain level, on which the sub-process is created, is increased by one level from the first level scheduling domain to the second level scheduling domain according to a scheduling domain, in which the core on which the process is loaded, so that the sub-process runs in the core within the range of the second level scheduling domain.
[0010] Further, the step S101 further comprises:
[0011] S1011, respectively performing affinity judgment on all the sub-processes created by the process within the preset period, and if the sub-processes and the process satisfy preset affinity conditions, setting affinity marks for the corresponding sub-processes.
[0012] Further, the step S102 further comprises:
[0013] S1021, running the sub-processes with the affinity marks in the cores within the range of the first level scheduling domain.
[0014] Further, the step S1011 further comprises:
[0015] judging whether a run queue of the core on which the process runs has idle queues greater than a preset idle number, and if yes, skipping the step S1011.
[0016] Further, the preset design value is decreased by a preset attenuation value every other preset period.
[0017] Further, the scheduling method further comprises the following steps:
[0018] S103, returning to the step S102 after the preset period.
[0019] Further, the preset period is less than a scheduling period of the processor system.
[0020] In a second aspect, the application further provides a scheduling device of a parallel program, comprising:
[0021] a monitoring module, configured to monitor a process running in a first level scheduling domain of a processor system, and to assign a preset design value to the process according to a number of sub-processes created by the process within a preset period when the process runs;
[0022] a scheduling module, configured to compare the preset design value with a number of cores in the processor system, wherein:
[0023] If the preset number is greater than or equal to the number of the cores, a scheduling domain level, on which the child process is created, is increased from the first level scheduling domain to a second level scheduling domain according to a scheduling domain, in which the core on which the process is loaded, so that the child process runs in the core within the range of the second level scheduling domain.
[0024] In a third aspect, the present application provides a parallel program scheduling apparatus, comprising a memory, a processor and a parallel program scheduling program stored in the memory and executable on the processor, wherein the processor implements the steps of the parallel program scheduling method according to any one of the above embodiments when executing the parallel program scheduling program.
[0025] In a fourth aspect, the present application provides a storage medium, wherein the storage medium stores a parallel program scheduling program, and the processor implements the steps of the parallel program scheduling method according to any one of the above embodiments when executing the parallel program scheduling program.
[0026] The present application has the advantages that a parallel program scheduling method is provided, which monitors the creation behavior of a child process of a process, and adjusts the scheduling domain to make the parallel child process utilize more processor core resources at the initial stage of creation, while keeping the affinity setting of the original child process, thereby improving the utilization of processor resources while ensuring the interaction efficiency of the parallel program. BRIEF DESCRIPTION OF DRAWINGS
[0027] Figure 1 is a step flow block diagram of the parallel program scheduling method provided by the embodiments of the present application;
[0028] Figure 2 is a child process scheduling schematic diagram provided by the embodiments of the present application;
[0029] Figure 3 is a structure schematic diagram of the parallel program scheduling apparatus provided by the embodiments of the present application;
[0030] Figure 4 is a structure schematic diagram of another parallel program scheduling apparatus provided by the embodiments of the present application. DETAILED DESCRIPTION
[0031] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0032] Please refer to Figure 1 , Figure 1is a step flow block diagram of a scheduling method of a parallel program provided by an embodiment of the present application, and the scheduling method comprises the following steps:
[0033] S101, monitoring a process running in a first-level scheduling domain of a processor system, and when the process is running, assigning a preset value to the process according to a number of child processes created by the process in a preset period.
[0034] Specifically, the scheduling domain refers to a hierarchical structure in a computer system for managing and allocating resources and scheduling task execution, the scheduling domain level divides the resources and tasks in the system according to certain rules and levels, forms different scheduling domains, each scheduling domain is responsible for managing and scheduling a part of resources and tasks, and can cooperate and interact with other scheduling domains to realize efficient operation of the entire system. In the same scheduling domain, different scheduling groups can be further divided according to the definition of the scheduling domain.
[0035] The first-level scheduling domain in the embodiment of the present application is divided according to the cores in the processor system for allocating resources, and there is a concept of being contained between the first-level scheduling domain and the second-level scheduling domain in the following text, therefore, the number of cores contained in the first-level scheduling domain is not equal to the number of all cores in the processor system.
[0036] In a computer system, after a process is created, the core is allocated by the scheduler to run, when the parent process creates a child process, the child process is also allocated by the scheduler to run, in the embodiment of the present application, by monitoring when the process is about to create a child process, and confirming the number of child processes to be created, a preset value is assigned to the process, so as to realize subsequent process scheduling, it can be understood that the multiple child processes created by the same parent process at the same time belong to a parallel program. In the implementation process, the preset value can be realized in the process control block (task_struct) corresponding to the program.
[0037] S102, comparing the preset value with the number of cores in the processor system, wherein:
[0038] If the preset value is greater than or equal to the number of cores, according to the load of the core of the process, the scheduling domain level according to which the child process is created is increased by one level from the first-level scheduling domain to the second-level scheduling domain, so that the child process runs in the core within the range of the second-level scheduling domain.
[0039] For example, refer to Figure 2 , Figure 2This is a schematic diagram of child process scheduling provided in an embodiment of the present invention. Under the original processor scheduling strategy, since the scheduler only performs load balancing every large scheduling cycle, when child processes are first created, a large number of child processes are crowded and allocated to a small number of cores, such as... Figure 2 As shown in Figure A, cores 0-7 and 8-15 are in the same low-level scheduling domain. The parent process needs to create 32 child processes, while there are only 16 cores in the corresponding low-level scheduling domain. At this time, each core is evenly distributed to 2 child processes to run. If the total number of cores in the system is 32, then half of the cores are not under load, resulting in a waste of resources.
[0040] Based on the technical solution of this invention, in the early stages when a process needs to create child processes, a pre-designed value is used to mark the 32 child processes that need to be created. If the scheduler finds that the pre-designed value has reached the number of global system cores, then core allocation will be performed in the current lower-level scheduling domain, which will increase the likelihood of process congestion. In this case, if... Figure 2 As shown in Figure B, the scheduling domain level used when creating a child process is increased from the first-level scheduling domain (lower-level scheduling domain) to the second-level scheduling domain (higher-level scheduling domain). This increases the number of cores available for allocation. If the system contains a total of 32 cores, then each core will have a load, compared to... Figure 2 In the case of A, the utilization of cores in the processor system is improved, and process congestion is reduced.
[0041] Preferably, in order to maintain the affinity settings between the process and the child process, step S101 further includes:
[0042] S1011. Perform affinity judgment on all the child processes created by the process within the preset period. If the child process and the process meet the preset affinity condition, set an affinity flag for the corresponding child process.
[0043] In computer systems, affinity refers to the characteristic that a process tends to run on a specific processor core or set of processors. In this embodiment of the invention, affinity is mainly used to determine whether a child process is configured to run on the same core as other child processes or the parent process. During implementation, the affinity flag can be implemented based on the `want_affine` parameter (in Linux systems).
[0044] Step S102 also includes:
[0045] S1021. Run the subprocess with the affinity tag within the core of the first-level scheduling domain.
[0046] In the implementation process, the specific core allocation of the sub-process with the affinity label is performed by the scheduler. In fact, there is a certain mechanism for the affinity process allocation in the prior method, but it is mainly based on the overall core load condition in the processor system for allocation. The affinity process creation principle in the embodiment of the application is performed on the basis of the scheduling domain level adjustment described in the above embodiment, and the purpose is to improve the core utilization rate while ensuring the use of core affinity.
[0047] In the processor system, before step S1011, there is also:
[0048] It is judged whether the running queue of the core running the process has an idle queue greater than the preset idle quantity. If yes, step S1011 is skipped.
[0049] Due to the existing processor architecture, the core can realize the processing of multiple processes through the queue mechanism, and under a certain number of queues, the load of the core can be ensured not to be too large. In the embodiment of the application, the degree of idle of the process queue of the core is judged to perform the affinity label processing. It can be understood that if all the cores are idle at this time, the sub-process allocation can be performed according to the original processor process allocation mechanism.
[0050] Preferably, in order to realize continuous parallel program scheduling, the preset design value is reduced by a preset attenuation value every other preset period.
[0051] The scheduling method further includes the following steps:
[0052] S103, after the preset period, return to step S102.
[0053] The preset period is less than the scheduling period of the processor system. Through the preset design value in the embodiment of the application, the rapid balanced scheduling of the process can be realized in a shorter time relative to the scheduling period of the system level. By attenuating the preset design value, the length of the execution time can be reflected to a certain extent, so that in the whole scheduling process, as the preset design value attenuates, the scheduler can also continue to maintain the affinity setting between the processes when performing scheduling.
[0054] It can be understood that the scheduling method of the parallel program in the embodiment of the application is implemented based on the existing processor mechanism, and in step S102, when the preset value of the process is judged, if the process does not meet the condition of adjusting the scheduling domain for process allocation, the processor system can be executed according to the original process allocation mechanism. In the implementation process, the scheduling method proposed in the embodiment of the application can be manually opened and closed by setting a switch parameter in the kernel and according to the actual use of the core, so as to realize the controllable adjustment of the processor mechanism.
[0055] The application achieves the beneficial effects, that is, a scheduling method of a parallel program is provided, which monitors the sub-process creation behavior of a process, and adjusts the scheduling domain to enable the parallel sub-process to utilize more processor core resources in the initial creation stage, while maintaining the affinity setting of the original sub-process, thereby improving the utilization of processor resources while ensuring the interaction efficiency of the parallel program.
[0056] The embodiment of the application also provides a scheduling device 200 of a parallel program, which will be described below with reference to Figure 3 , Figure 3 The scheduling device of the parallel program provided by the embodiment of the application is shown in the structure diagram, which comprises:
[0057] The monitoring module 201 is configured to monitor the process running in the first-level scheduling domain of the processor system, and when the process runs, a preset value is given to the process according to the number of sub-processes created by the process in a preset period.
[0058] The scheduling module 202 is configured to compare the preset value with the number of cores in the processor system, wherein:
[0059] If the preset value is greater than or equal to the number of cores, the scheduling domain level followed by the sub-process when created is increased by one from the first-level scheduling domain to the second-level scheduling domain according to the scheduling domain where the cores loaded by the process are located, so that the sub-process runs in the cores within the range of the second-level scheduling domain.
[0060] The scheduling device 200 of the parallel program can realize the steps in the scheduling method of the parallel program in the above embodiment, and can realize the same technical effects. For the description in the above embodiment, details are not repeated here.
[0061] The embodiment of the application also provides another scheduling device 300 of a parallel program, which will be described below with reference to Figure 4 , Figure 4Figure 1 is a structural schematic diagram of a parallel program scheduling device provided by an embodiment of the present application, the parallel program scheduling device 300 comprising a memory 302, a processor 301, and a parallel program scheduling program stored in the memory 302 and capable of running on the processor 301.
[0062] The processor 301 invokes the parallel program scheduling program stored in the memory 302 to execute the steps in the parallel program scheduling method provided by an embodiment of the present application, please refer to Figure 1 , which specifically comprises the following steps:
[0063] S101, monitor a process running in a first-level scheduling domain of a processor system, and when the process is running, assign a preset value to the process according to the number of child processes created by the process within a preset period.
[0064] S102, compare the preset value with the number of cores in the processor system, wherein:
[0065] If the preset value is greater than or equal to the number of cores, increase the scheduling domain level according to which the child processes are created by one from the first-level scheduling domain to a second-level scheduling domain, so that the child processes run on the cores within the range of the second-level scheduling domain.
[0066] Preferably, in order to maintain the affinity setting between the process and the child processes, step S101 further comprises:
[0067] S1011, respectively perform affinity judgment on all the child processes created by the process within the preset period, and if the child processes satisfy a preset affinity condition with the process, set an affinity mark for the corresponding child processes.
[0068] Step S102 further comprises:
[0069] S1021, run the child processes with the affinity mark on the cores within the range of the first-level scheduling domain.
[0070] In the processor system, before step S1011, there further comprises:
[0071] Judging whether the run queue of the core on which the process runs has idle queues greater than a preset idle number, and if yes, skip step S1011.
[0072] Preferably, in order to realize continuous parallel program scheduling, the preset value is decreased by a preset attenuation value every other preset period. In the implementation process, the unit of the preset period is Hz.
[0073] The scheduling method further comprises the following steps:
[0074] S103, after the preset period, returning to step S102.
[0075] The preset period is less than a scheduling period of the processor system.
[0076] The parallel program scheduling device 300 provided by the embodiment of the present application can realize the steps in the parallel program scheduling method in the above embodiment, and can realize the same technical effects. Please refer to the description in the above embodiment, which will not be repeated here.
[0077] The embodiment of the present application further provides a storage medium, and the storage medium stores a parallel program scheduling program. When the parallel program scheduling program is executed by a processor, each process and step in the parallel program scheduling method provided by the embodiment of the present application is realized, and the same technical effects can be realized. To avoid repetition, this will not be repeated here.
[0078] Those skilled in the art can understand that all or part of the processes in the above embodiment method can be completed by a parallel program scheduling program to instruct related hardware (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to complete. The program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above embodiment of each method. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.
[0079] It should be noted that in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, methods, articles, or devices including a series of elements not only include those elements, but also include other elements not explicitly listed, or include elements inherent to such processes, methods, articles, or devices. Without more limitations, the element defined by the statement "including a" does not exclude the presence of additional identical elements in the process, method, article, or device including the element.
[0080] The embodiments of the present application are described above in combination with the drawings, and the disclosed is only the preferred embodiment of the present application, but the present application is not limited to the above specific embodiments. The above specific embodiments are only illustrative, but not restrictive. Those skilled in the art can make many equivalent changes in form without departing from the purpose of the present application and the scope protected by the claims, which are all within the protection of the present application.
Claims
1. A method of scheduling a parallel program, characterized by, The scheduling method comprises the following steps: S101, monitoring a process running in a first-level scheduling domain in a processor system, and assigning a preset value to the process according to the number of child processes created by the process within a preset period when the process is running; the preset period is shorter than a scheduling period of the processor system; S102, comparing the preset value with the number of cores in the processor system, wherein: if the preset value is greater than or equal to the number of cores, increasing the scheduling domain level from the first-level scheduling domain to a second-level scheduling domain according to the scheduling domain where the cores loaded with the process are located, so that the child processes run in the cores within the range of the second-level scheduling domain; S103, returning to step S102 after the preset period; wherein the preset value is decreased by a preset attenuation value every other preset period.
2. The method of claim 1, wherein, Step S101 further comprises: S1011, performing affinity judgment on all the child processes created by the process within the preset period respectively, and setting an affinity mark for the corresponding child process if the child process and the process satisfy a preset affinity condition.
3. The method of claim 2, wherein, Step S102 further comprises: S1021, running the child process with the affinity mark in the cores within the range of the first-level scheduling domain.
4. The method of claim 2, wherein, Before step S1011, further comprising: judging whether the run queue of the cores where the process runs has idle queues greater than a preset idle number, and skipping step S1011 if yes.
5. A scheduling apparatus of a parallel program, characterized by comprising: Comprise: a monitoring module for monitoring a process running in a first-level scheduling domain in a processor system, and assigning a preset value to the process according to the number of child processes created by the process within a preset period when the process is running; the preset period is shorter than a scheduling period of the processor system; a scheduling module for comparing the preset value with the number of cores in the processor system, wherein: if the preset value is greater than or equal to the number of cores, increasing the scheduling domain level from the first-level scheduling domain to a second-level scheduling domain according to the scheduling domain where the cores loaded with the process are located, so that the child processes run in the cores within the range of the second-level scheduling domain; an adjusting module for returning to the scheduling module after the preset period; wherein the preset value is decreased by a preset attenuation value every other preset period.
6. A scheduling apparatus of a parallel program, characterized by comprising: Comprise: a memory, a processor, and a parallel program scheduling program stored in the memory and executable on the processor, wherein the processor implements the steps in the parallel program scheduling method according to any one of claims 1-4 when executing the parallel program scheduling program.
7. A storage medium, characterized by The storage medium stores a parallel program scheduling program, and the parallel program scheduling program implements the steps in the parallel program scheduling method according to any one of claims 1-4 when executed by a processor.
Citation Information
Patent Citations
Processor multi-thread concurrence method
CN111427686A
Scheduling method and system for Direct IO intensive tasks under NUMA architecture
CN119473564A
