CN112130977B - Task scheduling method, device, equipment and medium - Google Patents

Task scheduling method, device, equipment and medium Download PDF

Info

Publication number
CN112130977B
CN112130977B CN202011023777.1A CN202011023777A CN112130977B CN 112130977 B CN112130977 B CN 112130977B CN 202011023777 A CN202011023777 A CN 202011023777A CN 112130977 B CN112130977 B CN 112130977B
Authority
CN
China
Prior art keywords
executed
task
subtasks
variable
shared
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011023777.1A
Other languages
Chinese (zh)
Other versions
CN112130977A (en
Inventor
刘同强
王朝辉
李拓
周玉龙
邹晓峰
童元满
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Original Assignee
Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd filed Critical Shandong Yunhai Guochuang Cloud Computing Equipment Industry Innovation Center Co Ltd
Priority to CN202011023777.1A priority Critical patent/CN112130977B/en
Publication of CN112130977A publication Critical patent/CN112130977A/en
Application granted granted Critical
Publication of CN112130977B publication Critical patent/CN112130977B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • G06F9/5066Algorithms for mapping a plurality of inter-dependent sub-tasks onto a plurality of physical CPUs

Abstract

The application discloses a task scheduling method, a device, equipment and a medium, wherein the method comprises the following steps: acquiring a task to be executed, and dividing the task to be executed into a plurality of subtasks to be executed in parallel; determining the number of shared variables among the subtasks to be executed; grouping the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed; and allocating each task group to be executed to a corresponding CPU, and allocating storage space for variables in the tasks to be executed so that the CPUs can execute the subtasks to be executed in the allocated task groups to be executed. Therefore, the subtasks with higher coupling degree can be distributed to the same CPU, the problem of subtask blocking is avoided, the task execution efficiency is improved, and the data processing efficiency and performance of the whole computer system are further improved.

Description

Task scheduling method, device, equipment and medium
Technical Field
The present application relates to the field of multi-core computer technologies, and in particular, to a method, an apparatus, a device, and a medium for task scheduling.
Background
The multi-core processor is a mainstream Central Processing Unit (CPU) architecture for business at present, and adopts a mode that a plurality of processor cores are integrated into one chip, and all the processor cores can access all physical memories, so that the management is easy, and the multi-core processor is widely applied. The multi-core programming design usually adopts a multi-task mode design, and tasks are parallelly distributed to each processor core for execution, wherein a typical programming model is a shared memory programming model.
Referring to fig. 1, in a UMA (Unified Memory Architecture) Architecture, each CPU implements coherent storage, and each CPU can access a Memory through a Memory controller. Referring to fig. 2, different processors on the same CPU may access the same local cache, and threads running on different processors are independent from each other, and implicit communication between different threads is achieved by accessing the cache.
For the particularity of a program running under the UMA architecture, a parallel programming language can divide an initial task into a plurality of subtasks which can be executed in parallel at present, and an operating system distributes the subtasks to each CPU according to the hardware condition. However, in this allocation mode, the operating system scheduling module is only a mechanical scheduling subtask, which may cause frequent access operations between subtasks running inside different CPUs when a subtask with a higher coupling degree is allocated to different CPUs, resulting in a problem of subtask blocking, thereby causing low task execution efficiency, further causing a reduction in data processing efficiency of the entire computer system, and reducing performance of the computer system.
Disclosure of Invention
In view of this, an object of the present application is to provide a task scheduling method, device, apparatus, and medium, which can allocate a sub-task with a higher coupling degree to the same CPU, avoid the problem of sub-task blocking, improve task execution efficiency, and further improve data processing efficiency and performance of the whole computer system. The specific scheme is as follows:
in a first aspect, the present application discloses a task scheduling method, applied to a multi-core computer, including:
acquiring a task to be executed, and dividing the task to be executed into a plurality of subtasks to be executed in parallel;
determining the number of shared variables among the subtasks to be executed;
grouping the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed;
and allocating each task group to be executed to a corresponding CPU, and allocating storage space for variables in the tasks to be executed so that the CPUs can execute the subtasks to be executed in the allocated task groups to be executed.
Optionally, the grouping the to-be-executed subtasks based on the number of the shared variables to obtain different to-be-executed task groups includes:
sequencing the number of the shared variables from large to small to obtain a sequence of the number of the shared variables;
and grouping the subtasks to be executed based on the data size in the shared variable quantity sequence to obtain different task groups to be executed.
Optionally, the allocating each task group to be executed to a corresponding CPU includes:
judging whether the number of the task groups to be executed is less than or equal to the number of CPUs in the multi-core computer;
if yes, distributing a task group to be executed to a CPU;
and if not, classifying the task groups to be executed to obtain task classes to be executed, wherein one task class to be executed comprises one or more task groups to be executed.
Optionally, the classifying the group of tasks to be executed to obtain a class of tasks to be executed includes:
classifying the task groups to be executed based on the number of shared variables among the task groups to be executed to obtain task classes to be executed;
or classifying the task groups to be executed based on the number of subtasks in each task group to be executed to obtain the task classes to be executed.
Optionally, allocating a storage space for any variable in the task to be executed includes:
determining the number of subtasks accessing the variable in each task group to be executed;
and storing the variable to a storage address accessed by the task group to be executed corresponding to the maximum subtask number.
Optionally, in the process of storing the variable to the storage address accessed by the to-be-executed task group corresponding to the maximum number of the subtasks, the method further includes:
if the number of the maximum subtasks is larger than 1, determining the stored variable number under the storage address accessed by the task group to be executed corresponding to each maximum subtask number;
and storing the variable to a storage address accessed by the task group to be executed corresponding to the minimum stored variable number.
Optionally, the determining the number of shared variables between the to-be-executed subtasks includes
Determining a shared variable in each subtask to be executed to obtain a shared variable set, wherein the shared variable is a variable accessed by the current subtask to be executed and other subtasks to be executed except the current subtask to be executed;
constructing a variable attribute table based on the shared variable set, wherein the variable attribute table is used for representing the condition that each shared variable is accessed by each subtask to be executed;
and determining the number of shared variables among the subtasks to be executed based on the variable attribute table.
In a second aspect, the present application discloses a task scheduling apparatus, which is applied to a multi-core computer, and includes:
the task acquisition module is used for acquiring a task to be executed;
the task splitting module is used for dividing the task to be executed into a plurality of parallel executed subtasks to be executed;
a shared variable determining module, configured to determine the number of shared variables among the to-be-executed subtasks;
the subtask grouping module is used for grouping the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed;
and the task allocation module is used for allocating each task group to be executed to the corresponding CPU and allocating storage space for the variables in the task to be executed so that the CPU can execute the subtasks to be executed in the allocated task group to be executed.
In a third aspect, the present application discloses a multi-core computer comprising:
a memory and a processor;
wherein the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the task scheduling method disclosed above.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the task scheduling method disclosed above.
It can be seen that, according to the present application, a task to be executed is obtained, the task to be executed is divided into a plurality of sub tasks to be executed, which are executed in parallel, then the number of shared variables among the sub tasks to be executed is determined, then the sub tasks to be executed are grouped based on the number of the shared variables, so as to obtain different task groups to be executed, then each task group to be executed is allocated to a corresponding CPU, and a storage space is allocated to variables in the task to be executed, so that the CPU executes the sub tasks to be executed in the allocated task groups to be executed. Therefore, after dividing the task to be executed into a plurality of sub tasks to be executed which can be executed in parallel, the number of shared variables among the sub tasks to be executed is determined, the sub tasks to be executed are grouped based on the number of the shared variables among the sub tasks to be executed, so that the coupling between the sub tasks to be executed in the same sub task group to be executed is high, the coupling between the sub tasks to be executed in different sub task groups to be executed is low, and after the different sub task groups to be executed are distributed to different CPUs, the problem of blocking of the sub tasks to be executed caused by frequent access and storage operation among the sub tasks to be executed in different CPUs is avoided, the task execution efficiency is improved, and the data processing efficiency and the performance of the whole computer system are improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a schematic diagram of a multi-core computer architecture as disclosed herein;
FIG. 2 is a schematic diagram of a multi-core computer architecture according to the present disclosure;
FIG. 3 is a flowchart of a task scheduling method disclosed herein;
FIG. 4 is a table of specific variable attributes disclosed herein;
FIG. 5 is a table of specific shared variable numbers disclosed herein;
FIG. 6 is a schematic diagram of a task scheduler according to the present disclosure;
FIG. 7 is a schematic diagram of a multi-core computer architecture according to the present disclosure.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 3, an embodiment of the present application discloses a task scheduling method, which is applied to a multi-core computer, and includes:
step S11: the method comprises the steps of obtaining a task to be executed, and dividing the task to be executed into a plurality of sub tasks to be executed which are executed in parallel.
In a specific implementation process, a task to be executed needs to be acquired first, and the task to be executed needs to be divided into a plurality of sub tasks to be executed, which can be executed in parallel. That is, it is necessary to first obtain a task to be executed, and then analyze the task to be executed, so as to divide the task to be executed into a plurality of sub tasks to be executed that can be executed in parallel, so that the sub tasks to be executed can be executed in parallel, and thus, the task execution efficiency can be improved. The plurality of parallel executed to-be-executed subtasks are greater than or equal to 2 to-be-executed subtasks. The method for dividing the task to be executed into a plurality of to-be-executed subtasks which can be executed in parallel is not particularly limited, and may be determined according to specific situations.
Step S12: and determining the number of the shared variables among the subtasks to be executed.
After dividing the to-be-executed subtasks into a plurality of to-be-executed subtasks which can be executed in parallel, the number of shared variables among the to-be-executed subtasks also needs to be determined, so that the to-be-executed subtasks with a large number of shared variables are divided into the same to-be-executed subtask group.
Specifically, the determining the number of shared variables between the to-be-executed subtasks includes: determining a shared variable in each subtask to be executed to obtain a shared variable set, wherein the shared variable is a variable accessed by the current subtask to be executed and other subtasks to be executed except the current subtask to be executed; constructing a variable attribute table based on the shared variable set, wherein the variable attribute table is used for representing the condition that each shared variable is accessed by each subtask to be executed; and determining the number of shared variables among the subtasks to be executed based on the variable attribute table.
Firstly, the shared variables in each subtask to be executed are counted to obtain a shared variable set. For example, the shared variables in each to-be-executed subtask are as follows:
the shared variables in the to-be-executed subtask 0 are: a, b, c, d, e, f, g, h, i, j, k, l.
The shared variables in the to-be-executed subtask 1 are: h, i, j, k, l, m, n, o, p, r, s, t.
The shared variables in the subtask 2 to be executed are: k, l, m, n, o, p, r, s, t, u, v, w.
The shared variables in the to-be-executed subtask 3 are: aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll.
The shared variables in the to-be-executed subtask 4 are: aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, mm.
The shared variables in the to-be-executed subtask 5 are: there are no shared variables.
The shared variables in the subtask 6 to be executed are: a, b, c, d, e, f.
The shared variables in the to-be-executed subtask 7 are: k, l, m, n, o, p, r, s, t, u, v, w, kk, mm.
The shared variables in the subtask 8 to be executed are: a, b, c, d, e, g.
The obtained set of shared variables is: a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r, s, t, u, v, w, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm.
Accordingly, the variable attribute table constructed based on the above-mentioned shared variable set is shown in fig. 4, in which if the shared variable is accessed by the subtask, it is 1, otherwise it is 0. The shared variables between the subtasks in the variable attribute table are counted, and the number of the shared variables between the subtasks is shown in fig. 5. In the figure, a represents the subtask itself and the shared variable situation of itself. It can thus be seen that the number of shared variables between subtasks 2 and 7 is 12, the number of shared variables between subtasks 3 and 4 is 11, the number of shared variables between subtasks 2 and 1 is 9, the number of shared variables between subtasks 1, 6 and 8 is 6, the number of shared variables between subtasks 0 and 1, and between subtasks 6 and 8 is 5, and the number of shared variables between subtasks 0, 2 and 7 is 2.
Step S13: and grouping the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed.
After the number of the shared variables among the subtasks to be executed is determined, the subtasks to be executed can be grouped based on the number of the shared variables, so that different task groups to be executed are obtained. Specifically, the shared variable number may be sorted from large to small to obtain a shared variable number sequence, and then each to-be-executed subtask is grouped based on the size of data in the shared variable number sequence to obtain different to-be-executed task groups.
For example, the number of shared variables shown in fig. 5 may be sorted from large to small into 12 for the number of shared variables between the subtasks 2 and 7, 11 for the number of shared variables between the subtasks 3 and 4, 9 for the number of shared variables between the subtasks 2 and 1, 6 for the number of shared variables between the subtasks 1, 6 and 8, 5 for the number of shared variables between the subtasks 0 and 1 and 6 and 8, and 2 for the number of shared variables between the subtasks 0, 2 and 7, the subtasks 2, 7, 3 and 4 may be divided into one to-be-executed task group, the subtasks 0, 1, 6 and 8 may be divided into one to-be-executed task group, and the subtask 5 is not shared variable, and therefore may be used alone as one to-be-executed task group. Of course, there may be more elaborate grouping methods, and no specific limitation is made here.
Step S14: and allocating each task group to be executed to a corresponding CPU, and allocating storage space for variables in the tasks to be executed so that the CPUs can execute the subtasks to be executed in the allocated task groups to be executed.
After dividing each to-be-executed subtask into a specific to-be-executed task group, it is also necessary to allocate each to-be-executed task group to a corresponding CPU, and allocate a storage space for a variable in the to-be-executed task, so that the CPU executes the to-be-executed subtask in the allocated to-be-executed task group.
Specifically, it may be determined whether the number of the task groups to be executed is less than or equal to the number of CPUs in the multicore computer; if yes, distributing a task group to be executed to a CPU; if not, classifying the task groups to be executed to obtain task groups to be executed, wherein one task group to be executed comprises one or more task groups to be executed.
That is, whether one task group to be executed can be allocated to one CPU is firstly checked, if so, one task group to be executed is allocated to one CPU, and the CPU can execute each sub-task to be executed in the task group to be executed in parallel through a plurality of processors of the CPU. If the number of the CPUs in the multi-core computer is less than the number of the task groups to be executed, some CPUs are divided into a plurality of task groups to be executed, so that the task groups to be executed need to be classified first to obtain task groups to be executed, wherein one task group to be executed comprises one or more task groups to be executed, and the task groups to be executed comprise more than or equal to 2 task groups to be executed.
In the process of classifying the task groups to be executed to obtain task classes to be executed, classifying the task groups to be executed based on the number of shared variables among the task groups to be executed to obtain task classes to be executed; or classifying the task groups to be executed based on the number of subtasks in each task group to be executed to obtain the task classes to be executed.
That is, the classification may be performed based on the number of shared variables between the to-be-executed task groups, for example, if the number of shared variables between the to-be-executed task group 1 and the to-be-executed task group 2 is 10, and the number of shared variables between the to-be-executed task group 1 and the to-be-executed task group 3 is 6, the to-be-executed task group 1 and the to-be-executed task group 2 are classified into the same to-be-executed task class. Alternatively, the classification may be performed based on the number of subtasks in each of the task groups to be executed. For example, if the task group 1 to be executed includes 3 subtasks, the task group 2 to be executed includes 1 subtask, and the task group 3 to be executed includes 6 subtasks, the task group 1 to be executed and the task group 2 to be executed may be divided into the same task class to be executed.
In addition, it is also necessary to allocate a storage space for the variable accessed by the task to be executed. Specifically, allocating a storage space for any variable in the task to be executed includes: determining the number of subtasks needing to access the variable in each task group to be executed; and storing the variable to a storage address accessed by the task group to be executed corresponding to the maximum subtask number. That is, the variable is allocated to the memory address accessed by the task group to be executed, when the number of the subtasks in the task group to be executed needs to access the variable is more.
In the process of storing the variable to the storage address accessed by the task group to be executed corresponding to the maximum subtask number, the method further comprises the following steps: if the number of the maximum subtasks is larger than 1, determining the stored variable number under the storage address accessed by the task group to be executed corresponding to each maximum subtask number; and storing the variable to a storage address accessed by the task group to be executed corresponding to the minimum stored variable number. That is, in practical applications, when the number of subtasks that need to access the current variable in different to-be-executed task groups is the same, the number of stored variables in the storage address accessed by the to-be-executed task group corresponding to each maximum subtask number may be determined first, and the variable may be stored in the storage address accessed by the to-be-executed task group corresponding to the minimum number of stored variables.
It can be seen that, according to the present application, a task to be executed is obtained, the task to be executed is divided into a plurality of sub tasks to be executed, which are executed in parallel, then the number of shared variables among the sub tasks to be executed is determined, then the sub tasks to be executed are grouped based on the number of the shared variables, so as to obtain different task groups to be executed, then each task group to be executed is allocated to a corresponding CPU, and a storage space is allocated to variables in the task to be executed, so that the CPU executes the sub tasks to be executed in the allocated task groups to be executed. Therefore, after dividing the tasks to be executed into the subtasks to be executed which can be executed in parallel, the number of the shared variables among the subtasks to be executed is determined, and the subtasks to be executed are grouped based on the number of the shared variables among the subtasks to be executed, so that the coupling between the subtasks to be executed in the same subtask group to be executed is high, the coupling between the subtasks to be executed in different subtask groups to be executed is low, and after different subtask groups to be executed are distributed to different CPUs, the problem of blocking of the subtasks to be executed caused by frequent access and storage operation among the subtasks to be executed in different CPUs is avoided, the task execution efficiency is improved, and the data processing efficiency and the performance of the whole computer system are improved.
In a specific application, the task scheduling method may be implemented by a scheduling algorithm, the scheduling algorithm may be run on a processor of the multicore computer and used as a patch of a task scheduling module of an operating system of the multicore computer, after task grouping and variable address allocation are completed, the scheduling algorithm allocates group allocation and shared variable address allocation to generate a script, and the operating system scheduling module first reads the variable address allocation script, allocates the variable address allocation script to a specific address according to the group, and reads the group script to perform subtask scheduling.
Referring to fig. 6, an embodiment of the present application discloses a task scheduling apparatus, which is applied to a multi-core computer, and includes:
the task obtaining module 11 is configured to obtain a task to be executed;
the task splitting module 12 is configured to divide the to-be-executed task into a plurality of to-be-executed subtasks that are executed in parallel;
a shared variable determining module 13, configured to determine the number of shared variables among the to-be-executed subtasks;
a subtask grouping module 14, configured to group the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed;
and the task allocation module 15 is configured to allocate each to-be-executed task group to a corresponding CPU, and allocate a storage space to a variable in the to-be-executed task, so that the CPU executes a to-be-executed sub task in the allocated to-be-executed task group.
It can be seen that, according to the present application, a task to be executed is obtained, the task to be executed is divided into a plurality of sub tasks to be executed, which are executed in parallel, then the number of shared variables among the sub tasks to be executed is determined, then the sub tasks to be executed are grouped based on the number of the shared variables, so as to obtain different task groups to be executed, then each task group to be executed is allocated to a corresponding CPU, and a storage space is allocated to variables in the task to be executed, so that the CPU executes the sub tasks to be executed in the allocated task groups to be executed. Therefore, after dividing the tasks to be executed into the subtasks to be executed which can be executed in parallel, the number of the shared variables among the subtasks to be executed is determined, and the subtasks to be executed are grouped based on the number of the shared variables among the subtasks to be executed, so that the coupling between the subtasks to be executed in the same subtask group to be executed is high, the coupling between the subtasks to be executed in different subtask groups to be executed is low, and after different subtask groups to be executed are distributed to different CPUs, the problem of blocking of the subtasks to be executed caused by frequent access and storage operation among the subtasks to be executed in different CPUs is avoided, the task execution efficiency is improved, and the data processing efficiency and the performance of the whole computer system are improved.
Further, the subtask grouping module 14 is configured to:
sequencing the number of the shared variables from large to small to obtain a sequence of the number of the shared variables;
and grouping the subtasks to be executed based on the data size in the shared variable quantity sequence to obtain different task groups to be executed.
Specifically, the task allocation module 15 is configured to:
judging whether the number of the task groups to be executed is less than or equal to the number of CPUs in the multi-core computer;
if yes, distributing a task group to be executed to a CPU;
if not, classifying the task groups to be executed to obtain task groups to be executed, wherein one task group to be executed comprises one or more task groups to be executed.
Specifically, the task allocation module 15 is configured to:
classifying the task groups to be executed based on the number of shared variables among the task groups to be executed to obtain task classes to be executed;
or classifying the task groups to be executed based on the number of subtasks in each task group to be executed to obtain the task classes to be executed.
Specifically, the task allocation module 15 is configured to:
determining the number of subtasks needing to access the variable in each task group to be executed;
and storing the variable to a storage address accessed by the task group to be executed corresponding to the maximum subtask number.
Specifically, the task allocation module 15 is configured to:
if the number of the maximum subtasks is larger than 1, determining the stored variable number under the storage address accessed by the task group to be executed corresponding to each maximum subtask number;
and storing the variable to a storage address accessed by the task group to be executed corresponding to the minimum stored variable number.
Further, the shared variable determining module 13 is configured to:
determining a shared variable in each subtask to be executed to obtain a shared variable set, wherein the shared variable is a variable accessed by the current subtask to be executed and other subtasks to be executed except the current subtask to be executed;
constructing a variable attribute table based on the shared variable set, wherein the variable attribute table is used for representing the condition that each shared variable is accessed by each subtask to be executed;
and determining the number of shared variables among the subtasks to be executed based on the variable attribute table.
Referring to fig. 7, a schematic structural diagram of a multicore computer 20 provided in the embodiment of the present application is shown, where the multicore computer 20 may implement the task scheduling method disclosed in the foregoing embodiment.
Generally, the multicore computer 20 in the present embodiment includes: a processor 21 and a memory 22.
Wherein the processor 21 includes a plurality of processing cores, such as a four-core processor, an eight-core processor, and the like. The processor 21 may be implemented by at least one hardware of a DSP (digital signal processing), an FPGA (field-programmable gate array), and a PLA (programmable logic array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (graphics processing unit) which is responsible for rendering and drawing images to be displayed on the display screen. In some embodiments, the processor 21 may include an AI (artificial intelligence) processor for processing a calculation operation related to machine learning.
Memory 22 may include one or more computer-readable storage media, which may be non-transitory. Memory 22 may also include high speed random access memory, as well as non-volatile memory, such as one or more magnetic disk storage devices, flash memory storage devices. In this embodiment, the memory 22 is at least used for storing the following computer program 221, wherein after being loaded and executed by the processor 21, the steps of the task scheduling method disclosed in any one of the foregoing embodiments can be implemented.
In some embodiments, the multi-core computer 20 may also include a display screen 23, an input output interface 24, a communication interface 25, sensors 26, a power supply 27, and a communication bus 28.
Those skilled in the art will appreciate that the architecture shown in FIG. 7 is not intended to be limiting of the multi-core computer 20 and may include more or fewer components than those shown.
Further, an embodiment of the present application also discloses a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the task scheduling method disclosed in any of the foregoing embodiments.
For the specific process of the task scheduling method, reference may be made to corresponding contents disclosed in the foregoing embodiments, and details are not described herein again.
The embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts among the embodiments are referred to each other. The device disclosed in the embodiment corresponds to the method disclosed in the embodiment, so that the description is simple, and the relevant points can be referred to the description of the method part.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of other elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The above detailed description is given to a task scheduling method, a task scheduling device, a task scheduling apparatus, and a task scheduling medium, and a specific example is applied in the detailed description to explain the principle and the implementation of the present application, and the description of the above embodiment is only used to help understanding the method and the core idea of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (8)

1. A task scheduling method is applied to a multi-core computer and comprises the following steps:
acquiring a task to be executed, and dividing the task to be executed into a plurality of subtasks to be executed in parallel;
determining the number of shared variables among the subtasks to be executed;
grouping the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed;
allocating each task group to be executed to a corresponding CPU, and allocating storage space for variables in the task to be executed so that the CPU executes the subtasks to be executed in the allocated task group to be executed, wherein the grouping of the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed comprises: sequencing the number of the shared variables from large to small to obtain a sequence of the number of the shared variables; grouping the subtasks to be executed based on the data size in the shared variable quantity sequence to obtain different task groups to be executed;
the allocating each task group to be executed to a corresponding CPU includes: judging whether the number of the task groups to be executed is less than or equal to the number of CPUs in the multi-core computer; if yes, distributing a task group to be executed to a CPU; if not, classifying the task groups to be executed to obtain task groups to be executed, wherein one task group to be executed comprises one or more task groups to be executed.
2. The task scheduling method according to claim 1, wherein the classifying the group of tasks to be executed to obtain a class of tasks to be executed comprises:
classifying the task groups to be executed based on the number of shared variables among the task groups to be executed to obtain task classes to be executed;
or classifying the task groups to be executed based on the number of subtasks in each task group to be executed to obtain the task classes to be executed.
3. The task scheduling method according to claim 1, wherein allocating a storage space for any variable in the task to be executed comprises:
determining the number of subtasks accessing the variable in each task group to be executed;
and storing the variable to a storage address accessed by the task group to be executed corresponding to the maximum subtask number.
4. The task scheduling method according to claim 3, wherein the storing the variable to the storage address accessed by the to-be-executed task group corresponding to the maximum number of subtasks further comprises:
if the number of the maximum subtasks is larger than 1, determining the stored variable number under the storage address accessed by the task group to be executed corresponding to each maximum subtask number;
and storing the variable to a storage address accessed by the task group to be executed corresponding to the minimum stored variable number.
5. The task scheduling method according to any one of claims 1 to 4, wherein the determining the number of shared variables between the to-be-executed subtasks includes:
determining a shared variable in each subtask to be executed to obtain a shared variable set, wherein the shared variable is a variable accessed by the current subtask to be executed and other subtasks to be executed except the current subtask to be executed;
constructing a variable attribute table based on the shared variable set, wherein the variable attribute table is used for representing the condition that each shared variable is accessed by each subtask to be executed;
and determining the number of shared variables among the subtasks to be executed based on the variable attribute table.
6. A task scheduling apparatus applied to a multi-core computer, comprising:
the task acquisition module is used for acquiring a task to be executed;
the task splitting module is used for dividing the task to be executed into a plurality of parallel executed subtasks to be executed;
a shared variable determining module, configured to determine the number of shared variables among the to-be-executed subtasks;
the subtask grouping module is used for grouping the subtasks to be executed based on the number of the shared variables to obtain different task groups to be executed;
the task allocation module is used for allocating each task group to be executed to a corresponding CPU and allocating storage space for variables in the task to be executed so that the CPU executes the subtasks to be executed in the allocated task group to be executed;
the subtask grouping module is specifically configured to sort the shared variable number from large to small to obtain a shared variable number sequence; grouping the subtasks to be executed based on the data size in the shared variable quantity sequence to obtain different task groups to be executed;
the task allocation module is specifically configured to determine whether the number of the task groups to be executed is less than or equal to the number of CPUs in the multicore computer; if yes, distributing a task group to be executed to a CPU; if not, classifying the task groups to be executed to obtain task groups to be executed, wherein one task group to be executed comprises one or more task groups to be executed.
7. A multi-core computer, comprising:
a memory and a processor;
wherein the memory is used for storing a computer program;
the processor is configured to execute the computer program to implement the task scheduling method according to any one of claims 1 to 5.
8. A computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the task scheduling method according to any one of claims 1 to 5.
CN202011023777.1A 2020-09-25 2020-09-25 Task scheduling method, device, equipment and medium Active CN112130977B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011023777.1A CN112130977B (en) 2020-09-25 2020-09-25 Task scheduling method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011023777.1A CN112130977B (en) 2020-09-25 2020-09-25 Task scheduling method, device, equipment and medium

Publications (2)

Publication Number Publication Date
CN112130977A CN112130977A (en) 2020-12-25
CN112130977B true CN112130977B (en) 2022-08-02

Family

ID=73839851

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011023777.1A Active CN112130977B (en) 2020-09-25 2020-09-25 Task scheduling method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN112130977B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115456188B (en) * 2022-02-28 2024-04-05 本源量子计算科技(合肥)股份有限公司 Quantum computing task optimization processing method and device and quantum computer

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101339523A (en) * 2007-07-05 2009-01-07 国际商业机器公司 Multi-processor environment assembly line processing method and equipment
CN105900064A (en) * 2014-11-19 2016-08-24 华为技术有限公司 Method and apparatus for scheduling data flow task
CN109144720A (en) * 2018-07-13 2019-01-04 哈尔滨工程大学 A kind of multi-core processor task schedule selection method based on shared resource sensitivity
EP3443456A1 (en) * 2016-04-12 2019-02-20 Telefonaktiebolaget LM Ericsson (PUBL) Process scheduling in a processing system having at least one processor and shared hardware resources
CN109791506A (en) * 2016-10-10 2019-05-21 瑞典爱立信有限公司 Task schedule
CN110647390A (en) * 2019-09-20 2020-01-03 西安交通大学 Parallel task allocation scheduling method based on locality quantization for multi-core system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101339523A (en) * 2007-07-05 2009-01-07 国际商业机器公司 Multi-processor environment assembly line processing method and equipment
CN105900064A (en) * 2014-11-19 2016-08-24 华为技术有限公司 Method and apparatus for scheduling data flow task
EP3443456A1 (en) * 2016-04-12 2019-02-20 Telefonaktiebolaget LM Ericsson (PUBL) Process scheduling in a processing system having at least one processor and shared hardware resources
CN109791506A (en) * 2016-10-10 2019-05-21 瑞典爱立信有限公司 Task schedule
CN109144720A (en) * 2018-07-13 2019-01-04 哈尔滨工程大学 A kind of multi-core processor task schedule selection method based on shared resource sensitivity
CN110647390A (en) * 2019-09-20 2020-01-03 西安交通大学 Parallel task allocation scheduling method based on locality quantization for multi-core system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Low-cost variable-length FFT processor for DVB-T/H applications;Kisun Jung,Hanho Lee;《IEEE Xplore》;20110527;全文 *
马尔科夫链蒙特卡洛算法并行化设计与性能分析;周玉科,刘建文,王妍;《计算机应用与软件》;20171231;第34卷(第12期);全文 *

Also Published As

Publication number Publication date
CN112130977A (en) 2020-12-25

Similar Documents

Publication Publication Date Title
US9465734B1 (en) Coalition based memory management
CN110704360B (en) Graph calculation optimization method based on heterogeneous FPGA data flow
CA2828264C (en) System and method for batch evaluation programs
CN114741207B (en) GPU resource scheduling method and system based on multi-dimensional combination parallelism
JP7039631B2 (en) Methods, devices, devices, and storage media for managing access requests
CN110308982B (en) Shared memory multiplexing method and device
JP2015146154A (en) Job scheduling apparatus, job scheduling method and job scheduling program
CN112711478A (en) Task processing method, device, server and storage medium based on neural network
US11720496B2 (en) Reconfigurable cache architecture and methods for cache coherency
WO2020253117A1 (en) Data processing method and apparatus
US11687242B1 (en) FPGA board memory data reading method and apparatus, and medium
CN111708639A (en) Task scheduling system and method, storage medium and electronic device
US20180046474A1 (en) Method for executing child kernels invoked on device side utilizing dynamic kernel consolidation and related non-transitory computer readable medium
CN112130977B (en) Task scheduling method, device, equipment and medium
CN111767023A (en) Data sorting method and data sorting system
CN105637482A (en) Method and device for processing data stream based on gpu
US11561826B1 (en) Scheduling processing of machine learning tasks on heterogeneous compute circuits
CN115237599B (en) Rendering task processing method and device
JP6156379B2 (en) Scheduling apparatus and scheduling method
US20210374319A1 (en) Dynamic allocation of computing resources for electronic design automation operations
CN113535087B (en) Data processing method, server and storage system in data migration process
US11556377B2 (en) Storage medium, task execution management device, and task execution management method
CN111444430B (en) Content recommendation method, device, equipment and storage medium
CN110415162B (en) Adaptive graph partitioning method facing heterogeneous fusion processor in big data
CN110837419A (en) Inference engine system and method based on elastic batch processing and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant