Mechanism for scheduling threads on a multiprocessor
An apparatus to facilitate thread scheduling is disclosed. The apparatus includes logic to store barrier usage data based on a magnitude of barrier messages in an application kernel and a scheduler to schedule execution of threads across a plurality of multiprocessors based on the barrier usage data.
1. An apparatus comprising:
a processor to analyze an application kernel to determine a magnitude of barrier messages in the application kernel and generate barrier usage data having a value corresponding to the magnitude of barrier messages in the application kernel;
a memory to store the barrier usage data; and
a graphics processor, including:
a plurality of multiprocessors; and
a scheduler to retrieve the barrier usage data from the memory and to schedule execution of each thread of a plurality of threads to a respective microprocessor of the plurality of multiprocessors according to a scheduling policy, the scheduling policy being based at least in part on the barrier usage data, wherein the scheduler is to prioritize scheduling threads of a thread group to a same microprocessor of the plurality of multiprocessors upon a determination that the barrier usage data indicates a high magnitude of barrier messages in the thread group.
2. The apparatus of claim 1 , wherein the memory is to store the barrier usage data as thread meta-data for the application kernel.
3. The apparatus of claim 1 , wherein the scheduling policy is based both on the barrier usage data and on load balancing of the plurality of threads across the plurality of multiprocessors.
4. The apparatus of claim 3 , wherein the scheduler is to perform the load balancing by performing a first cost function for each thread of the plurality of threads, the first cost function to determine a maximum number of threads scheduled for each of the plurality of multiprocessors.
5. The apparatus of claim 4 , wherein the scheduler is to perform a second cost function for each thread of the plurality of threads, the second cost function being based at least in part on the barrier usage data.
6. The apparatus of claim 5 , wherein the scheduler is to schedule the execution of each thread of the plurality of threads by minimizing a sum of values including the first cost function and the second cost function.
7. The apparatus of claim 1 , wherein the scheduler is to schedule the threads of the thread group for execution at two or more of the plurality of multiprocessors upon a determination that the barrier usage data indicates a low magnitude of barrier messages.
8. A method comprising:
analyzing an application kernel during compiling to determine a magnitude of barrier messages in the application kernel;
generating barrier usage data during the compiling having a value corresponding to the magnitude of barrier messages in the application kernel;
receiving a plurality of threads for scheduling; and
scheduling execution of each thread of the plurality of threads to a respective microprocessor of a plurality of multiprocessors according to a scheduling policy, the scheduling policy being based at least in part on the barrier usage data, wherein scheduling includes prioritizing the scheduling of threads of a thread group for execution to a same microprocessor of the plurality of multiprocessors upon a determination that the barrier usage data indicates a high magnitude of barrier messages in the thread group.
9. The method of claim 8 , further comprising storing the barrier usage data in a computer memory.
10. The method of claim 9 , wherein storing the barrier usage data includes storing the barrier usage data as thread meta-data for the application kernel.
11. The method of claim 8 , wherein the scheduling policy is based both on the barrier usage data and on load balancing of the plurality of threads across the plurality of multiprocessors.
12. The method of claim 11 , further comprising:
performing the load balancing by performing a first cost function for each thread of the plurality of threads, the first cost function to determine a maximum number of threads scheduled for each of the plurality of multiprocessors; and
performing a second cost function for each thread of the plurality of threads, the second cost function being based at least in part on the barrier usage data.
13. The method of claim 12 , further comprising scheduling the execution of each thread of the plurality of threads by minimizing a sum of values including the first cost function and the second cost function.
14. A non-transitory computer readable medium having instructions, which when executed by one or more processors, cause the processors to perform operations comprising:
analyzing an application kernel during compiling to determine a magnitude of barrier messages in the application kernel;
generating barrier usage data during the compiling having a value corresponding to the magnitude of barrier messages in the application kernel;
receiving a plurality of threads for scheduling; and
scheduling execution of each thread of the plurality of threads to a respective microprocessor of a plurality of multiprocessors according to a scheduling policy, the scheduling policy being based at least in part on the barrier usage data, wherein scheduling includes prioritizing the scheduling of threads of a thread group for execution to a same microprocessor of the plurality of multiprocessors upon a determination that the barrier usage data indicates a high magnitude of barrier messages in the thread group.
15. The computer readable medium of claim 14 , wherein the scheduling policy is based both on the barrier usage data and on load balancing of the plurality of threads across the plurality of multiprocessors.
16. The computer readable medium of claim 15 , having instructions, which when executed by the one or more processors, further cause the processors to perform operations comprising:
performing the load balancing by performing a first cost function for each thread of the plurality of threads, the first cost function to determine a maximum number of threads scheduled for each of the plurality of multiprocessors; and
performing a second cost function for each thread of the plurality of threads, the second cost function being based at least in part on the barrier usage data.
17. The computer readable medium of claim 16 , having instructions, which when executed by the one or more processors, further cause the processors to perform operations comprising:
scheduling the execution of each thread of the plurality of threads by minimizing a sum of values including the first cost function and the second cost function.