pt.runtime
Class AbstractTaskPool

java.lang.Object
  extended by pt.runtime.AbstractTaskPool
All Implemented Interfaces:
Taskpool
Direct Known Subclasses:
TaskpoolFIFOWorkSharing, TaskpoolLIFOWorkStealing, TaskpoolMixedScheduling

public abstract class AbstractTaskPool
extends java.lang.Object
implements Taskpool


Field Summary
protected static java.util.Comparator<TaskID<?>> FIFO_TaskID_Comparator
           
protected  java.util.concurrent.PriorityBlockingQueue<TaskID<?>> globalTaskqueue
           
protected static int INITIAL_QUEUE_CAPACITY
           
protected  java.lang.ThreadLocal<java.lang.Integer> lastStolenFrom
           
protected static java.util.Comparator<TaskID<?>> LIFO_TaskID_Comparator
           
protected  java.util.Deque<TaskID<?>>[] localQueues
           
protected  FifoLifoQueue<TaskID<?>> mixedQueue
           
protected static int NOT_STOLEN
           
protected  int numThreads
           
protected  java.util.AbstractQueue<TaskID<?>>[] privateQueues
           
protected  java.util.concurrent.ConcurrentHashMap<TaskID<?>,java.lang.Object> waitingTasks
           
protected  WorkerThread[] workers
           
 
Constructor Summary
protected AbstractTaskPool()
           
 
Method Summary
 TaskID enqueue(TaskInfo taskinfo)
          Enqueues the specified task, whose information is contained in the TaskInfo.
 TaskIDGroup enqueueMulti(TaskInfo taskinfo, int count)
          Enqueues the specified TaskInfo as a multi-task, creates "count" inner tasks and places them in a TaskIDGroup which is then returned.
protected abstract  void enqueueReadyTask(TaskID<?> taskID)
           
protected  void enqueueWaitingTask(TaskID taskID, java.util.ArrayList<TaskID> allDependences)
           
 boolean executeSynchronously(int cutoff)
           
 int getActiveInteractiveTaskCount()
          Returns the count of currently active interactive tasks.
protected abstract  void initialise()
           
protected  void initialiseWorkerThreads()
           
 void interactiveTaskCompleted(TaskID<?> taskID)
          Used to decrement the count of interactive tasks
 void nowReady(TaskID<?> waiter)
          The specified task is currently on the waiting queue since it has some dependences.
 void printDebugInfo()
           
protected  void startInteractiveTask(TaskID taskID)
           
protected  void startPipelineTask(TaskID taskID)
           
 int totalNumTasksExecuted()
           
abstract  TaskID workerPollNextTask()
          The worker thread polls the task pool for a task..
 TaskID workerTakeNextTask()
          The worker thread blocks until it gets a task to execute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_QUEUE_CAPACITY

protected static final int INITIAL_QUEUE_CAPACITY
See Also:
Constant Field Values

FIFO_TaskID_Comparator

protected static final java.util.Comparator<TaskID<?>> FIFO_TaskID_Comparator

LIFO_TaskID_Comparator

protected static final java.util.Comparator<TaskID<?>> LIFO_TaskID_Comparator

numThreads

protected int numThreads

workers

protected WorkerThread[] workers

waitingTasks

protected java.util.concurrent.ConcurrentHashMap<TaskID<?>,java.lang.Object> waitingTasks

globalTaskqueue

protected java.util.concurrent.PriorityBlockingQueue<TaskID<?>> globalTaskqueue

mixedQueue

protected FifoLifoQueue<TaskID<?>> mixedQueue

privateQueues

protected java.util.AbstractQueue<TaskID<?>>[] privateQueues

localQueues

protected java.util.Deque<TaskID<?>>[] localQueues

lastStolenFrom

protected java.lang.ThreadLocal<java.lang.Integer> lastStolenFrom

NOT_STOLEN

protected static final int NOT_STOLEN
See Also:
Constant Field Values
Constructor Detail

AbstractTaskPool

protected AbstractTaskPool()
Method Detail

enqueueReadyTask

protected abstract void enqueueReadyTask(TaskID<?> taskID)

workerPollNextTask

public abstract TaskID workerPollNextTask()
Description copied from interface: Taskpool
The worker thread polls the task pool for a task.. If there isn't one, then it returns immediately (returns null in such a case).

Specified by:
workerPollNextTask in interface Taskpool
Returns:

initialise

protected abstract void initialise()

enqueue

public TaskID enqueue(TaskInfo taskinfo)
Description copied from interface: Taskpool
Enqueues the specified task, whose information is contained in the TaskInfo. It then returns a TaskID to represent that task.

Specified by:
enqueue in interface Taskpool
Returns:

enqueueMulti

public TaskIDGroup enqueueMulti(TaskInfo taskinfo,
                                int count)
Description copied from interface: Taskpool
Enqueues the specified TaskInfo as a multi-task, creates "count" inner tasks and places them in a TaskIDGroup which is then returned.

Specified by:
enqueueMulti in interface Taskpool
Returns:

workerTakeNextTask

public TaskID workerTakeNextTask()
Description copied from interface: Taskpool
The worker thread blocks until it gets a task to execute.

Specified by:
workerTakeNextTask in interface Taskpool
Returns:

getActiveInteractiveTaskCount

public int getActiveInteractiveTaskCount()
Description copied from interface: Taskpool
Returns the count of currently active interactive tasks. This is usually to know how many threads there are.

Specified by:
getActiveInteractiveTaskCount in interface Taskpool
Returns:

interactiveTaskCompleted

public void interactiveTaskCompleted(TaskID<?> taskID)
Description copied from interface: Taskpool
Used to decrement the count of interactive tasks

Specified by:
interactiveTaskCompleted in interface Taskpool
Parameters:
taskID - The task that has just completed

startInteractiveTask

protected void startInteractiveTask(TaskID taskID)

startPipelineTask

protected void startPipelineTask(TaskID taskID)

enqueueWaitingTask

protected void enqueueWaitingTask(TaskID taskID,
                                  java.util.ArrayList<TaskID> allDependences)

nowReady

public void nowReady(TaskID<?> waiter)
Description copied from interface: Taskpool
The specified task is currently on the waiting queue since it has some dependences. However, all thoses dependences have now been met and the task is ready to be scheduled for execution.

Specified by:
nowReady in interface Taskpool

initialiseWorkerThreads

protected void initialiseWorkerThreads()

executeSynchronously

public boolean executeSynchronously(int cutoff)
Specified by:
executeSynchronously in interface Taskpool

printDebugInfo

public void printDebugInfo()
Specified by:
printDebugInfo in interface Taskpool

totalNumTasksExecuted

public int totalNumTasksExecuted()
Specified by:
totalNumTasksExecuted in interface Taskpool