CN112346836B - Preemption method, device, user equipment and storage medium for shared computing resources - Google Patents
Preemption method, device, user equipment and storage medium for shared computing resources Download PDFInfo
- Publication number
- CN112346836B CN112346836B CN202011167440.8A CN202011167440A CN112346836B CN 112346836 B CN112346836 B CN 112346836B CN 202011167440 A CN202011167440 A CN 202011167440A CN 112346836 B CN112346836 B CN 112346836B
- Authority
- CN
- China
- Prior art keywords
- thread
- priority
- threads
- computing resources
- preemption
- 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
Links
- 238000000034 method Methods 0.000 title claims abstract description 51
- 239000000725 suspension Substances 0.000 claims abstract description 9
- 238000010586 diagram Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000004590 computer program Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005111 flow chemistry technique Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 235000003642 hunger Nutrition 0.000 description 1
- 230000009191 jumping Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/4881—Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/485—Task life-cycle, e.g. stopping, restarting, resuming execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/20—Processor architectures; Processor configuration, e.g. pipelining
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Multi Processors (AREA)
Abstract
本发明提供一种GPU多核处理器共享计算资源的抢占方法、装置及用户设备及存储介质。所述方法包括:管理调度线程从至少一个业务核或线程接收业务核或线程对应的线程池中的线程的优先级;所述管理调度线程判断是否所有的所述线程的优先级都一样;如果为是,则退出抢占处理流程,否则执行步骤3;所述管理调度线程获取当前执行的所有线程对应的优先级中的最低优先级;所述管理调度线程判断是否有比所述最低优先级高的所述线程没有获取到计算资源而执行;如果没有,则退出抢占处理流程;如果有,则进入步骤5;按优先级从低到高的顺序,选取正在执行的所述最低优先级对应的至少一个业务核或线程的任务,对选取的所述任务发起中止操作。
The present invention provides a preemption method, device, user equipment, and storage medium for GPU multi-core processors to share computing resources. The method includes: the management and scheduling thread receives the priority of the thread in the thread pool corresponding to the business core or thread from at least one business core or thread; the management and scheduling thread determines whether the priorities of all the threads are the same; if If yes, exit the preemption processing flow, otherwise execute step 3; the management scheduling thread obtains the lowest priority among the priorities corresponding to all currently executed threads; the management scheduling thread determines whether there is a thread with a higher priority than the lowest priority The threads are executed without obtaining computing resources; if not, exit the preemption processing flow; if yes, enter step 5; in order from low to high priority, select the thread corresponding to the lowest priority being executed The task of at least one business core or thread initiates a suspension operation on the selected task.
Description
技术领域Technical field
本发明涉及图形处理器技术领域,尤其涉及一种GPU多核处理器共享计算资源的抢占方法、装置及用户设备及存储介质。The present invention relates to the technical field of graphics processors, and in particular to a preemption method, device, user equipment, and storage medium for GPU multi-core processors to share computing resources.
背景技术Background technique
GPU采用流式并行计算模式,为了增加数据的并行处理效率,提升对底层计算资源(SIMD/DIMD)的充分利用,都会通过一个多核/多线程处理器来建立数据流处理计算通道,对计算任务的命令解析,配置相关信息,让计算资源(SIMD/DIMD)对数据进行计算处理。GPU adopts streaming parallel computing mode. In order to increase the efficiency of parallel processing of data and improve the full utilization of underlying computing resources (SIMD/DIMD), a multi-core/multi-thread processor will be used to establish a data flow processing computing channel to perform computing tasks. Parse the command, configure relevant information, and let the computing resources (SIMD/DIMD) calculate and process the data.
每个核/线程都对应一个线程池(如图2的虚线),线程池中有多个线程(线程和所执行计算任务的优先级一一对应),每个核/线程都会从自己管理的线程池中选择一个线程来执行,调度方式主要是优先级与时间片,这样每个线程池中的线程都能实现重要计算任务优先分发,同等优先级的按时间片切换,确保重要任务执行后,普通任务再正常执行,以达到计算效率的最大化。Each core/thread corresponds to a thread pool (the dotted line in Figure 2). There are multiple threads in the thread pool (threads correspond to the priorities of the computing tasks performed). Each core/thread will manage it from its own Select a thread in the thread pool for execution. The scheduling method is mainly priority and time slice, so that the threads in each thread pool can achieve priority distribution of important computing tasks, and switch with the same priority according to the time slice to ensure that important tasks are executed after , ordinary tasks are then executed normally to maximize computing efficiency.
在实现本发明的过程中,发明人发现现有技术中至少存在如下技术问题:In the process of realizing the present invention, the inventor found that there are at least the following technical problems in the prior art:
现有技术中没有考虑多核/线程之间的线程调度。每个核/线程都执行各自线程池中最高优先级的计算任务,就存在当前线程池的高优先级任务将计算资源(SIMD/DIMD)耗尽,导致其他核/线程池中比当前线程高的优先级任务由于获取不到计算资源而无法执行的情况。Thread scheduling among multiple cores/threads is not considered in the prior art. Each core/thread executes the highest-priority computing task in its respective thread pool. If there are high-priority tasks in the current thread pool, the computing resources (SIMD/DIMD) will be exhausted, causing other cores/thread pools to have higher priority than the current thread. Priority tasks cannot be executed due to unavailability of computing resources.
发明内容Contents of the invention
本发明提供GPU多核处理器共享计算资源的抢占方法、装置及用户设备及存储介质,能够确保所有线程池中高优先级任务能够得到及时执行。The present invention provides a GPU multi-core processor shared computing resource preemption method, device, user equipment and storage medium, which can ensure that high-priority tasks in all thread pools can be executed in time.
一方面,提供一种GPU多核处理器共享计算资源的抢占方法,包括:On the one hand, a preemption method for shared computing resources of GPU multi-core processors is provided, including:
步骤1,管理调度线程从至少一个业务核或线程接收业务核或线程对应的线程池中的线程的优先级;Step 1: The management scheduling thread receives the priority of the thread in the thread pool corresponding to the business core or thread from at least one business core or thread;
步骤2,所述管理调度线程判断是否所有的所述线程的优先级都一样;如果为是,则退出抢占处理流程,否则执行步骤3;Step 2: The management scheduling thread determines whether the priorities of all the threads are the same; if yes, exit the preemption processing flow, otherwise execute step 3;
步骤3,所述管理调度线程获取当前执行的所有线程对应的优先级中的最低优先级;Step 3: The management scheduling thread obtains the lowest priority among the priorities corresponding to all currently executed threads;
步骤4,所述管理调度线程判断是否有比所述最低优先级高的所述线程没有获取到计算资源而执行;如果没有,则退出抢占处理流程;如果有,则进入步骤5;Step 4: The management scheduling thread determines whether there is a thread with a higher priority than the lowest priority that has not obtained computing resources and is executed; if not, exit the preemption processing flow; if there is, enter step 5;
步骤5,按优先级从低到高的顺序,所述管理调度线程选取正在执行的所述最低优先级对应的至少一个业务核或线程的任务,对选取的所述任务发起中止操作,保存中止的所述任务的现场,并释放对应的计算资源,以使得比所述最低优先级高的任务被执行。Step 5: In order of priority from low to high, the management scheduling thread selects the task of at least one business core or thread corresponding to the lowest priority being executed, initiates a suspension operation on the selected task, and saves the suspension. of the task and release the corresponding computing resources so that tasks with a higher priority than the lowest priority are executed.
可选的,所述方法还包括:Optionally, the method also includes:
步骤6,跳转到所述步骤1。Step 6: Jump to step 1.
可选的,所述方法步骤6之前,所述方法还包括:Optionally, before step 6 of the method, the method further includes:
所述管理调度线程提高被中止的所述线程的优先级。The management scheduling thread increases the priority of the suspended thread.
可选的,所述步骤2之前,所述方法还包括:Optionally, before step 2, the method further includes:
所述管理调度线程根据所述优先级,对所述线程进行排序。The management scheduling thread sorts the threads according to the priority.
可选的,所述的步骤1之前,所述方法还包括:Optionally, before step 1, the method further includes:
GPU多核处理器创建管理调度线程。GPU multi-core processors create and manage scheduling threads.
另一方面,提供一种GPU多核处理器共享计算资源的抢占装置,包括:On the other hand, a preemption device for shared computing resources of GPU multi-core processors is provided, including:
接收单元,用于从至少一个业务核或线程接收业务核或线程对应的线程池中的线程的优先级;A receiving unit, configured to receive from at least one business core or thread the priority of the thread in the thread pool corresponding to the business core or thread;
第一判断单元,用于断是否所有的所述线程的优先级都一样;如果为是,则退出抢占处理流程,否则启动获取单元;The first judgment unit is used to determine whether the priorities of all the threads are the same; if yes, exit the preemption processing flow, otherwise start the acquisition unit;
获取单元,用于获取当前执行的所有线程对应的优先级中的最低优先级;The acquisition unit is used to obtain the lowest priority among the priorities corresponding to all threads currently executing;
第二判断单元,用于判断是否有比所述最低优先级高的所述线程没有获取到计算资源而执行;如果没有,则退出抢占处理流程;如果有,则启动选择单元;The second judgment unit is used to judge whether the thread with a higher priority than the lowest priority has not obtained the computing resource and is executed; if not, exit the preemption processing flow; if there is, start the selection unit;
选择单元,用于按优先级从低到高的顺序,所述管理调度线程选取正在执行的所述最低优先级对应的至少一个业务核或线程的任务,对选取的所述任务发起中止操作,保存中止的所述任务的现场,并释放对应的计算资源,以使得比所述最低优先级高的任务被执行。A selection unit configured to select, in order of priority from low to high, the management scheduling thread to select at least one business core or thread task corresponding to the lowest priority being executed, and initiate a suspension operation on the selected task, The scene of the suspended task is saved, and the corresponding computing resources are released, so that tasks with a higher priority than the lowest priority are executed.
所述的装置,还包括:The device also includes:
提高单元,用于提高被中止的所述线程的优先级。An increasing unit, used to increase the priority of the suspended thread.
另一方面,提供一种用户设备,所述用户设备包括所述的GPU多核处理器共享计算资源的抢占装置。On the other hand, a user equipment is provided, which includes the preemption device for shared computing resources of a GPU multi-core processor.
另一方面,提供一种GPU多核处理器共享计算资源的抢占装置,包括:On the other hand, a preemption device for shared computing resources of GPU multi-core processors is provided, including:
存储器;memory;
以及耦接至所述存储器的处理器,所述处理器被配置为基于存储在所述存储器中的指令,执行所述的GPU多核处理器共享计算资源的抢占方法。and a processor coupled to the memory, the processor being configured to execute the preemption method for shared computing resources by a GPU multi-core processor based on instructions stored in the memory.
另一方面,提供一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机指令,所述计算机指令被处理器执行时实现所述的GPU多核处理器共享计算资源的抢占方法。On the other hand, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the method for preempting shared computing resources of a GPU multi-core processor is implemented .
本发明实施例中,在GPU流处理器的多核/多线程之间增加了抢占流程,确保所有线程池中高优先级任务能够得到及时执行。In the embodiment of the present invention, a preemption process is added between the multi-cores/multi-threads of the GPU stream processor to ensure that high-priority tasks in all thread pools can be executed in time.
附图说明Description of the drawings
图1为本发明一实施例所述的GPU多核处理器共享计算资源的抢占方法的流程图;Figure 1 is a flow chart of a preemption method for shared computing resources by a GPU multi-core processor according to an embodiment of the present invention;
图2为本发明另一实施例所述的GPU多核处理器共享计算资源的抢占方法所用的系统框架示意图;FIG. 2 is a schematic diagram of the system framework used in the preemption method for shared computing resources of a GPU multi-core processor according to another embodiment of the present invention;
图3为本发明另一实施例所述的GPU多核处理器共享计算资源的抢占方法的流程图;Figure 3 is a flow chart of a preemption method for shared computing resources by a GPU multi-core processor according to another embodiment of the present invention;
图4为本发明一实施例所述的GPU多核处理器共享计算资源的抢占装置的结构示意图;Figure 4 is a schematic structural diagram of a preemption device for shared computing resources by a GPU multi-core processor according to an embodiment of the present invention;
图5为本发明另一实施例所述的GPU多核处理器共享计算资源的抢占装置的结构示意图。FIG. 5 is a schematic structural diagram of a preemption device for shared computing resources by a GPU multi-core processor according to another embodiment of the present invention.
具体实施方式Detailed ways
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments These are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
如图1所示,为本发明所述的一种GPU多核处理器共享计算资源的抢占方法,包括:As shown in Figure 1, it is a preemption method for GPU multi-core processor shared computing resources according to the present invention, including:
步骤11,管理调度线程从至少一个业务核或线程接收业务核或线程对应的线程池中的线程的优先级;该步骤之前,所述方法还包括:GPU多核处理器创建管理调度线程。业务核/线程在按“时间片+优先级”执行线程池中计算任务时,将当前执行任务的优先级告知管理核/线程,使得调度管理的核/线程可以统计所有核/线程执行任务的优先级。Step 11: The management scheduling thread receives the priority of the thread in the thread pool corresponding to the business core or thread from at least one business core or thread; before this step, the method also includes: the GPU multi-core processor creates a management scheduling thread. When the business core/thread executes the computing task in the thread pool according to "time slice + priority", it informs the management core/thread of the priority of the currently executed task, so that the scheduled and managed core/thread can count the number of tasks executed by all cores/threads. priority.
步骤12,所述管理调度线程判断是否所有的所述线程的优先级都一样;如果为是,则退出抢占处理流程,否则执行步骤3;可选的,所述步骤12之前,所述方法还包括:所述管理调度线程根据所述优先级,对所述线程进行排序。Step 12: The management scheduling thread determines whether the priorities of all the threads are the same; if yes, exit the preemption processing flow, otherwise execute step 3; optionally, before step 12, the method also It includes: the management and scheduling thread sorts the threads according to the priority.
步骤13,所述管理调度线程获取当前执行的所有线程对应的优先级中的最低优先级;Step 13: The management scheduling thread obtains the lowest priority among the priorities corresponding to all currently executed threads;
步骤14,所述管理调度线程判断是否有比所述最低优先级高的所述线程没有获取到计算资源而执行;如果没有,则退出抢占处理流程;如果有,则进入步骤15;Step 14: The management scheduling thread determines whether there is a thread with a higher priority than the lowest priority that has not obtained computing resources and is executed; if not, exit the preemption processing flow; if there is, enter step 15;
步骤15,按优先级从低到高的顺序,所述管理调度线程选取正在执行的所述最低优先级对应的至少一个业务核或线程的任务,对选取的所述任务发起中止操作,并释放对应的计算资源,以使得比所述最低优先级高的任务被执行。同时,保存中止的所述任务的现场,使得下次根据保存的现场重新发起执行。Step 15: In order of priority from low to high, the management scheduling thread selects the task of at least one business core or thread corresponding to the lowest priority being executed, initiates a suspension operation on the selected task, and releases the task. Corresponding computing resources are used so that tasks with a higher priority than the lowest priority are executed. At the same time, the scene of the suspended task is saved, so that execution can be reinitiated based on the saved scene next time.
步骤16,所述管理调度线程提高被中止的所述线程的优先级。提高优先级可以提高一级或者几级,根据实际情况设定。确保高优先级任务被及时执行,低优先级任务又不会被“饿死”。Step 16: The management scheduling thread increases the priority of the suspended thread. The priority level can be raised by one or more levels, depending on the actual situation. Ensure that high-priority tasks are executed in a timely manner and low-priority tasks are not "starved to death."
可选的,所述方法还包括:跳转到所述步骤11,继续进行处理。由于多核/多线程是并行执行的,所以可能出现高优先级仍然获取不到计算资源的情况,所以需要回到步骤11进行重新检查。Optionally, the method also includes: jumping to step 11 and continuing processing. Since multi-cores/multi-threads are executed in parallel, it may happen that high priority still cannot obtain computing resources, so you need to go back to step 11 and recheck.
本发明具有以下有益效果:The invention has the following beneficial effects:
1、本发明主要是针对在GPU多核/多线程的流处理器中,增加多核/多线程之间按优先级顺序实现抢占功能,确保所有线程池中高优先级的任务能够及时得到计算资源(SIMD/DIMD)而被及时执行。1. The present invention is mainly aimed at increasing the preemption function between multi-cores/multi-threads in order of priority in GPU multi-core/multi-thread stream processors to ensure that high-priority tasks in all thread pools can obtain computing resources in time (SIMD /DIMD) and be executed promptly.
2)对低优先级的线程采取了“中止+提升优先级”策略,保证了低优先级不会出现被“饿死”的情况。2) A "stop + increase priority" strategy is adopted for low-priority threads to ensure that low-priority threads will not be "starved to death".
也就是说,本发明避免了当计算资源(SIDM/DIMD)被低优先级任务耗尽,核/线程分发的高优先级计算任务无法执行的情况,同时杜绝了因抢占所导致低优先级计算任务被“饿死“的情况。支持优先级的GPU多核处理器中,所有核/线程执行的最高优先级任务能够优先交给计算资源(SIMD/MIMD)进行计算处理。不仅能实现线程池内部按优先级与时间片进行线程调度,线程池之间也能按照优先级进行线程调度,确保高优先级的线程的计算任务执行的同时,最大化GPU的计算效率。That is to say, the present invention avoids the situation that when computing resources (SIDM/DIMD) are exhausted by low-priority tasks, high-priority computing tasks distributed by cores/threads cannot be executed, and at the same time eliminates the problem of low-priority computing caused by preemption. The situation where the task is "starved to death". In GPU multi-core processors that support priority, the highest priority tasks executed by all cores/threads can be given priority to computing resources (SIMD/MIMD) for computing processing. Not only can threads be scheduled according to priority and time slice within the thread pool, but threads can also be scheduled according to priority between thread pools, ensuring that the computing tasks of high-priority threads are executed while maximizing the computing efficiency of the GPU.
本发明公开了一种实现GPU多核处理器共享计算资源(SIMD/MIMD)的抢占方法,针对图2虚线范围内的多核/多线程之间进行调度。本发明的主要设计理念为:通过对所有核/线程优先级进行统计,按照优先级从高到底进行排序,然后检查优先级最高核/线程的计算任务是否正在执行;如果没有执行,那么将正在执行的最低优先级核/线程的计算任务停止执行,保存现场,进入ready状态;然后最高优先级核/线程的计算任务就会得到执行,并将被替换的低优先级核/线程的优先级提升一级,确保高优先级任务被及时执行,低优先级任务又不会被“饿死”;如果最高优先级核/线程的任务已经在执行,则根据排序结果继续检查次高优先级,进行上述相同的操作,直到所有高优先级核/线程的计算任务都被执行,或者所有核/线程优先级相同,则退出抢占流程。在GPU多核/多线程处理器的多核/多线程之间增加优先级调度机制,通过对多核/多线程所执行任务的优先级进行调度,确保所有并行执行核/线程中高优先级任务能够优先得到计算资源(SIMD/MIMD)执行。The present invention discloses a preemption method for realizing GPU multi-core processor shared computing resources (SIMD/MIMD), aiming at scheduling between multi-cores/multi-threads within the dotted line range of Figure 2. The main design concept of the present invention is: by counting the priorities of all cores/threads, sorting them from high to low, and then checking whether the computing task of the highest priority core/thread is being executed; if it is not being executed, then it will be The execution of the computing task of the lowest priority core/thread stops execution, saves the scene, and enters the ready state; then the computing task of the highest priority core/thread will be executed and will be replaced by the priority of the lower priority core/thread. Raise one level to ensure that high-priority tasks are executed in time and low-priority tasks will not be "starved to death"; if the highest-priority core/thread task is already executing, continue to check the next-highest priority based on the sorting result. Perform the same operations as above until the computing tasks of all high-priority cores/threads are executed, or all cores/threads have the same priority, then exit the preemption process. A priority scheduling mechanism is added between the multi-cores/multi-threads of the GPU multi-core/multi-thread processor. By scheduling the priority of tasks executed by the multi-core/multi-thread, it ensures that high-priority tasks in all parallel execution cores/threads can be obtained first. Computing resources (SIMD/MIMD) execution.
在本发明设计中,多核/多线程分别针对各自线程池的任务采取“优先级+时间片”的策略不变,针对多核/多线程之间增加了按优先级抢占的策略,对当前所有正在执行线程的高优先级的计算任务的运行情况进行跟踪,确保高优先级任务能够得到及时执行。In the design of the present invention, multi-core/multi-thread respectively adopt the strategy of "priority + time slice" for the tasks of their respective thread pools unchanged, and a priority-based preemption strategy is added for multi-core/multi-thread. Track the running status of high-priority computing tasks of execution threads to ensure that high-priority tasks can be executed in a timely manner.
以下描述本发明另一实施例。如图3所示,所述方法包括的步骤如下:Another embodiment of the present invention is described below. As shown in Figure 3, the method includes the following steps:
步骤1,创建一个调度管理的核/线程,用于接受线程池中所有的业务线程发送过来的优先级信息,以根据接受到的信息,按照优先级的方式进行线程的管理调度。业务核/线程在按“时间片+优先级”执行线程池中计算任务时,将当前执行任务的优先级告知管理核/线程。调度管理的核/线程统计所有核/线程执行任务的优先级。Step 1: Create a scheduling management core/thread to receive the priority information sent by all business threads in the thread pool, and manage and schedule threads according to the priority based on the received information. When the business core/thread executes the computing task in the thread pool according to "time slice + priority", it informs the management core/thread of the priority of the currently executed task. The core/thread managed by the scheduler counts the priorities of all core/thread execution tasks.
步骤2,管理调度线程对上报的线程优先级信息按照优先级从高到低进行排序,然后检查排好序的优先级信息。如果所有的业务线程优先级都一样,那么说明不需要进行线程的抢占,退出抢占的流程,否则执行步骤3;Step 2: The management scheduling thread sorts the reported thread priority information from high to low priority, and then checks the sorted priority information. If the priorities of all business threads are the same, it means that there is no need to preempt the thread and exit the preemption process. Otherwise, proceed to step 3;
步骤3,依次获取高优先级任务;Step 3: Obtain high-priority tasks in sequence;
步骤4,根据从高到底的优先级顺序,依次检查执行次高优先级任务的业务核/线程是否获取到计算资源而执行。如果是,则进入步骤5。如果不是,则进入步骤6。Step 4: According to the priority order from high to low, check in turn whether the business core/thread executing the next highest priority task has obtained the computing resources for execution. If yes, proceed to step 5. If not, proceed to step 6.
步骤5,检测是否所有的高优先级任务的核/线程都获取到了计算资源。如果是,则退出抢占流程;如果不是,则进入步骤4,选择次一高优先级线程重复上述过程;Step 5: Check whether the cores/threads of all high-priority tasks have obtained computing resources. If yes, exit the preemption process; if not, proceed to step 4, select the next highest priority thread and repeat the above process;
步骤6,按优先级从低到高的顺序,选取低优先级且正在执行的核/线程,发起停止操作,保存低优先级线程对应计算任务的现场,释放对应的计算资源。Step 6: In order of priority from low to high, select the low-priority and executing core/thread, initiate a stop operation, save the scene of the computing task corresponding to the low-priority thread, and release the corresponding computing resources.
步骤7,提高被中止线程的优先级,防止由于抢占任务导致低优先级线程永远无法执行,出现“饿死“的情况。停止低优先级的核/线程的任务之后,再从步骤3执行。由于多核/多线程是并行执行的,所以可能出现高优先级仍然获取不到计算资源的情况,所以需要回到步骤3进行重新检查。Step 7: Increase the priority of the suspended thread to prevent low-priority threads from never being able to execute due to task preemption and "starving to death". After stopping the low-priority core/thread tasks, proceed from step 3. Since multi-cores/multi-threads are executed in parallel, it may happen that high priority still cannot obtain computing resources, so you need to go back to step 3 and recheck.
如图4所示,为本发明实施例所述的一种GPU多核处理器共享计算资源的抢占装置,包括:As shown in Figure 4, it is a preemption device for GPU multi-core processor shared computing resources according to an embodiment of the present invention, including:
接收单元,用于从至少一个业务核或线程接收业务核或线程对应的线程池中的线程的优先级;A receiving unit, configured to receive from at least one business core or thread the priority of the thread in the thread pool corresponding to the business core or thread;
第一判断单元,用于断是否所有的所述线程的优先级都一样;如果为是,则退出抢占处理流程,否则启动获取单元;The first judgment unit is used to determine whether the priorities of all the threads are the same; if yes, exit the preemption processing flow, otherwise start the acquisition unit;
获取单元,用于获取当前执行的所有线程对应的优先级中的最低优先级;The acquisition unit is used to obtain the lowest priority among the priorities corresponding to all threads currently executing;
第二判断单元,用于判断是否有比所述最低优先级高的所述线程没有获取到计算资源而执行;如果没有,则退出抢占处理流程;如果有,则启动选择单元;The second judgment unit is used to judge whether the thread with a higher priority than the lowest priority has not obtained the computing resource and is executed; if not, exit the preemption processing flow; if there is, start the selection unit;
选择单元,用于按优先级从低到高的顺序,所述管理调度线程选取正在执行的所述最低优先级对应的至少一个业务核或线程的任务,对选取的所述任务发起中止操作,保存中止的所述任务的现场,并释放对应的计算资源,以使得比所述最低优先级高的任务被执行。A selection unit configured to select, in order of priority from low to high, the management scheduling thread to select at least one business core or thread task corresponding to the lowest priority being executed, and initiate a suspension operation on the selected task, The scene of the suspended task is saved, and the corresponding computing resources are released, so that tasks with a higher priority than the lowest priority are executed.
本实施例的装置,可以用于执行上述方法实施例的技术方案,其实现原理和技术效果类似,此处不再赘述。The device of this embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principles and technical effects are similar and will not be described again here.
本发明实施例还提供一种用户设备,所述用户设备包括上述GPU多核处理器共享计算资源的抢占装置。An embodiment of the present invention also provides a user equipment, which includes the above-mentioned preemption device for GPU multi-core processor shared computing resources.
如图5所示,为本发明实施例还提供一种GPU多核处理器共享计算资源的抢占装置,包括:As shown in Figure 5, an embodiment of the present invention also provides a preemption device for GPU multi-core processors to share computing resources, including:
存储器602;memory 602;
以及耦接至所述存储器的处理器601,所述处理器被配置为基于存储在所述存储器中的指令,执行所述的GPU多核处理器共享计算资源的抢占方法。and a processor 601 coupled to the memory, the processor being configured to execute the preemption method for shared computing resources of a GPU multi-core processor based on instructions stored in the memory.
本发明实施例还提供一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机指令,所述计算机指令被处理器执行时实现所述的GPU多核处理器共享计算资源的抢占方法。Embodiments of the present invention also provide a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions. When the computer instructions are executed by the processor, the preemption of the shared computing resources of the GPU multi-core processor is realized. method.
本领域普通技术人员可以理解实现上述方法实施例中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)或随机存储记忆体(Random AccessMemory,RAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the above method embodiments can be implemented by instructing relevant hardware through a computer program. The program can be stored in a computer-readable storage medium. The program can be stored in a computer-readable storage medium. During execution, the process may include the processes of the embodiments of each of the above methods. The storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM) or a random access memory (Random Access Memory, RAM), etc.
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present invention. All are covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011167440.8A CN112346836B (en) | 2020-10-28 | 2020-10-28 | Preemption method, device, user equipment and storage medium for shared computing resources |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011167440.8A CN112346836B (en) | 2020-10-28 | 2020-10-28 | Preemption method, device, user equipment and storage medium for shared computing resources |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112346836A CN112346836A (en) | 2021-02-09 |
CN112346836B true CN112346836B (en) | 2023-11-21 |
Family
ID=74359195
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011167440.8A Active CN112346836B (en) | 2020-10-28 | 2020-10-28 | Preemption method, device, user equipment and storage medium for shared computing resources |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112346836B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114461396A (en) * | 2022-02-08 | 2022-05-10 | 亿咖通(湖北)技术有限公司 | LXC-based resource scheduling method, device, equipment and storage medium |
CN115311123B (en) * | 2022-08-11 | 2023-04-28 | 浙江中测新图地理信息技术有限公司 | Pixel stream GPU resource scheduling method and device |
CN116501475B (en) * | 2023-06-21 | 2023-10-20 | 杭州炬华科技股份有限公司 | Thread scheduling method, system and medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20110070299A (en) * | 2009-12-18 | 2011-06-24 | 한국전자통신연구원 | Task scheduling apparatus and method |
CN103324525A (en) * | 2013-07-03 | 2013-09-25 | 东南大学 | Task scheduling method in cloud computing environment |
CN106293902A (en) * | 2015-05-28 | 2017-01-04 | 宇龙计算机通信科技(深圳)有限公司 | A kind of processor scheduling method and system |
CN110457135A (en) * | 2019-08-09 | 2019-11-15 | 重庆紫光华山智安科技有限公司 | A kind of method of resource regulating method, device and shared GPU video memory |
CN111399989A (en) * | 2020-04-10 | 2020-07-10 | 中国人民解放军国防科技大学 | A container cloud-oriented task preemption scheduling method and system |
CN111736987A (en) * | 2020-05-29 | 2020-10-02 | 山东大学 | A task scheduling method based on GPU space resource sharing |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9575760B2 (en) * | 2013-05-17 | 2017-02-21 | Nvidia Corporation | Techniques for sharing priorities between streams of work and dynamic parallelism |
KR102641520B1 (en) * | 2018-11-09 | 2024-02-28 | 삼성전자주식회사 | System on chip including multi-core processor and task scheduling method thereof |
-
2020
- 2020-10-28 CN CN202011167440.8A patent/CN112346836B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
KR20110070299A (en) * | 2009-12-18 | 2011-06-24 | 한국전자통신연구원 | Task scheduling apparatus and method |
CN103324525A (en) * | 2013-07-03 | 2013-09-25 | 东南大学 | Task scheduling method in cloud computing environment |
CN106293902A (en) * | 2015-05-28 | 2017-01-04 | 宇龙计算机通信科技(深圳)有限公司 | A kind of processor scheduling method and system |
CN110457135A (en) * | 2019-08-09 | 2019-11-15 | 重庆紫光华山智安科技有限公司 | A kind of method of resource regulating method, device and shared GPU video memory |
CN111399989A (en) * | 2020-04-10 | 2020-07-10 | 中国人民解放军国防科技大学 | A container cloud-oriented task preemption scheduling method and system |
CN111736987A (en) * | 2020-05-29 | 2020-10-02 | 山东大学 | A task scheduling method based on GPU space resource sharing |
Also Published As
Publication number | Publication date |
---|---|
CN112346836A (en) | 2021-02-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112346836B (en) | Preemption method, device, user equipment and storage medium for shared computing resources | |
US8615765B2 (en) | Dividing a computer job into micro-jobs | |
US10802877B2 (en) | Task management methods and system, and computer storage medium | |
US9448864B2 (en) | Method and apparatus for processing message between processors | |
WO2024021489A1 (en) | Task scheduling method and apparatus, and kubernetes scheduler | |
CN101887383B (en) | Process real-time scheduling method | |
US20160210174A1 (en) | Hybrid Scheduler and Power Manager | |
JP2010165259A (en) | Apparatus and method for processing information | |
EP3376381A1 (en) | Resource management method and system, and computer storage medium | |
CN112925616A (en) | Task allocation method and device, storage medium and electronic equipment | |
CN109840149B (en) | Task scheduling method, device, equipment and storage medium | |
RU2453901C2 (en) | Hard-wired method to plan tasks (versions), system to plan tasks and machine-readable medium | |
CN114911591A (en) | Task scheduling method and system | |
CN103677959B (en) | A kind of virtual machine cluster migration method and system based on multicast | |
CN115904744A (en) | Thread locking method and device, electronic equipment and computer readable medium | |
CN111597044A (en) | Task scheduling method and device, storage medium and electronic equipment | |
EP2413240A1 (en) | Computer micro-jobs | |
US20230418667A1 (en) | Computing device for handling tasks in a multi-core processor, and method for operating computing device | |
CN109656716B (en) | Slurm job scheduling method and system | |
CN115695330B (en) | Scheduling system, method, terminal and storage medium for shreds in embedded system | |
JP2008225641A (en) | Computer system, interrupt control method and program | |
CN114035926A (en) | Application thread scheduling method and device, storage medium and electronic equipment | |
CN113032098A (en) | Virtual machine scheduling method, device, equipment and readable storage medium | |
CN117931412B (en) | A dual-core real-time operating system and task scheduling method | |
CN119225929A (en) | An optimization method, system, device and medium for ETL task scheduling |
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 |