Efficient processor load balancing using predication
A system and methods embodying some aspects of the present embodiments for efficient load balancing using predication flags are provided. The load balancing system includes a first processing unit, a second processing unit, and a shared queue. The first processing unit is in communication with a first queue. The second processing unit is in communication with a second queue. The first and second queues are each configured to hold a packet. The shared queue is configured to maintain a work assignment, wherein the work assignment is to be processed by either the first or second processing unit.
1. A method comprising:
reading a work assignment pointer from a packet, wherein the work assignment pointer points to a work assignment on a shared queue;
retrieving a work element, and a bit that indicates when the work assignment has been assigned to a processing unit, from the work assignment;
setting the bit in the work assignment; and
executing the work element associated with the work assignment when the retrieved bit is clear,
wherein the retrieving and the setting occur within a single clock cycle.
2. The method of claim 1 , wherein the retrieving and the setting comprise executing an atomic instruction.
3. The method of claim 1 , wherein the retrieving and the setting comprise executing a single instruction.
4. The method of claim 1 , wherein the retrieving the bit comprises storing the bit in memory.
5. The method of claim 1 , wherein the work element comprises the set of instructions to be executed.
6. The method of claim 1 , wherein the work element comprises a pointer to the set of instructions to be executed.
7. The method of claim 1 , further comprising:
storing the packet in a queue, wherein the packet is stored based on characteristics of a processing unit associated with the queue and characteristics of the work element.