public class JavaForkJoinRuntime extends Object implements HjRuntime
Constructor and Description |
---|
JavaForkJoinRuntime() |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Aborts the currently executing task.
|
HjMetrics |
abstractMetrics()
abstractMetrics.
|
<T> void |
asyncAwait(List<HjFuture<T>> dependences,
HjRunnable runnable)
Will execute the body of the runnable only after the dependences have been satisfied.
|
void |
asyncPhased(List<HjPhaserPair> phaserList,
HjSuspendable suspendable)
asyncPhased.
|
void |
asyncSeqAt(boolean sequentialize,
HjPlace place,
HjRunnable runnable)
Runs the body of code (possibly) asynchronously at the specified place.
|
void |
asyncSimt(long estimatedWorkInMilliseconds,
int maxParallelism,
int start,
int end,
HjSuspendingProcedureInt2D runnable)
asyncSimt
|
void |
asyncSuspAt(HjPlace place,
HjSuspendable suspendable)
Runs the body of code (possibly) asynchronously at the specified place.
|
<T> void |
asyncSuspAwait(List<HjFuture<T>> dependences,
HjSuspendable suspendable)
Will execute the body of the runnable only after the dependences have been satisfied.
|
void |
asyncWhen(HjExpression.HjAwaitExpression expression,
HjRunnable runnable)
Mechanism to create an asynchronous task where the await expression is designed to coordinate relationships of
this parallel tasks with other tasks (using the
HjFuture handles. |
protected void |
awaitLatch(ModCountDownLatch inFlightTaskCounter1) |
<T> void |
checkEureka(T eurekaValue) |
void |
cleanup()
Cleans up the runtime in anticipation for shutdown.
|
Object |
currentActivity()
Returns The currently executing activity.
|
HjPlace |
currentPlace() |
void |
doWait()
Perform the wait operation on all registered phasers in an activity.
|
void |
doWork(long n)
Registers n units of work against the currently running activity.
|
void |
dumpEventLog(PrintStream printStream)
Dumps the events tracked by the runtime.
|
void |
emergencyShutdown(Throwable cause)
Shutdown the runtime, this means also shutting down all places associated with this runtime and all currently
executing activities.
|
void |
finish(HjEureka<?,?,?> hjEureka,
HjSuspendable suspendable)
Registers a HjEureka with the finish scope and continues to execute the body of the finish scope.
|
void |
finish(HjSuspendable suspendable)
Runs the body of code in a finish block.
|
void |
finish(List<HjFinishAccumulator> accumulators,
HjSuspendable suspendable)
finish.
|
<T,V> HjFuture<V> |
futureAwait(List<HjFuture<T>> dependencies,
HjCallable<V> callable)
Equivalent of
HjRuntime.asyncAwait(java.util.List, HjRunnable) which returns a futureNb. |
<V> HjFuture<V> |
futureSeq(boolean sequentialize,
HjCallable<V> callable)
Creates an asynchronous task and returns the futureNb object representing the value of the computation.
|
<V> HjFuture<V> |
futureSusp(HjSuspendingCallable<V> callable)
Creates an asynchronous task and returns the futureNb object representing the value of the computation.
|
<T,V> HjFuture<V> |
futureSuspAwait(List<HjFuture<T>> dependencies,
HjSuspendingCallable<V> callable)
Equivalent of
HjRuntime.asyncAwait(java.util.List, HjRunnable) which returns a future. |
<V> HjFuture<V> |
futureWhen(HjExpression.HjAwaitExpression expression,
HjCallable<V> callable)
Mechanism to create an asynchronous task where the await expression is designed to coordinate relationships of
this parallel tasks with other tasks (using the
HjFuture handles. |
void |
initialize()
Initializes the runtime.
|
void |
isolated(HjRunnable runnable)
isolated.
|
void |
isolated(Object[] participants,
HjRunnable runnable)
Isolated statement identifies a critical section.
|
void |
isolated(Object participant,
HjRunnable runnable)
Isolated statement identifies a critical section.
|
<V> V |
isolatedWithReturn(HjCallable<V> callable)
isolatedWithReturn.
|
<V> V |
isolatedWithReturn(Object[] participants,
HjCallable<V> callable)
isolatedWithReturn.
|
<V> V |
isolatedWithReturn(Object participant,
HjCallable<V> callable)
isolatedWithReturn.
|
<L,R> HjBinaryEureka<L,R> |
newBinaryEureka(HjLogicalOperator operator,
HjEureka<L,Object,L> leftEureka,
HjEureka<R,Object,R> rightEureka)
Factory method to create a new
HjBinaryEureka instance. |
<T> HjConvergenceEureka<T> |
newConvergenceEureka(T initialValue,
java.util.function.BiPredicate<T,T> checker,
HjProcedure<T> convergenceCallback)
Factory method to create a new
HjConvergenceEureka instance. |
<T> HjCountEureka<T> |
newCountEureka(long numPhases,
int spaceForResult)
Factory method to create a new
HjCountEureka instance. |
<V> HjDataDrivenFuture<V> |
newDataDrivenFuture(boolean allowDuplicatePuts)
Factory method for a DataDrivenFuture.
|
<T> HjEngineEureka<T> |
newEngineEureka(int maxUnits)
Factory method to create a new
HjEngineEureka instance. |
HjEventCount |
newEventCount(int initialCount)
Returns a new instance of an HjEventCount.
|
<T> HjExtremaEureka<T> |
newExtremaEureka(T initialValue,
Comparator<T> comparator,
boolean shouldAbortOnOffer)
Factory method to create a new
HjExtremaEureka instance. |
HjFastBarrierEureka |
newFastBarrierEureka(int numPhases)
Factory method to create a new
HjFastBarrierEureka instance. |
HjFinishAccumulator |
newFinishAccumulator(HjOperator ope,
Class type)
newFinishAccumulator.
|
HjPhaser |
newPhaser(HjPhaserMode phaserMode,
int busyWaitLimit)
Create a new phaser in the specified registration mode..
|
<T> HjSearchEureka<T> |
newSearchEureka(T initialValue)
Factory method to create a new
HjSearchEureka instance. |
<T> HjTimerEureka<T> |
newTimerEureka(int timeUnitsInMillis)
Factory method to create a new
HjTimerEureka instance. |
<T> HjVersionEureka<T> |
newVersionEureka(int n)
Factory method to create a new
HjVersionEureka instance. |
void |
next()
Perform the next operation on all registered phasers in an activity.
|
int |
numWorkerThreads()
Returns the number of worker threads employed by the runtime for the current place.
|
<T> void |
offerEureka(T eurekaValue) |
<T> T |
readEureka()
Return the current value stored on the registered eureka.
|
Object |
readMode(Object wrappee)
readMode.
|
<T> HjEureka<T,T,T> |
retrieveEureka()
Return the eureka to be registered in the finish scope.
|
HjEventLogger |
retrieveEventLogger()
Retrieves the
HjEventLogger used by the runtime. |
void |
runKernel(HjSuspendable suspendable)
Entry of the user's program body into the Habanero runtime.
|
void |
scheduleActivity(HjPlace hjPlace,
Runnable runnable)
Schedules an activity whose body is represented by the
Runnable instance. |
void |
scheduleActivity(Runnable runnable)
Schedules an activity whose body is represented by the
Runnable instance. |
void |
signal()
Perform the signal operation on all registered phasers in an activity.
|
Object |
writeMode(Object wrappee)
writeMode.
|
public void initialize()
initialize
in interface HjRuntime
public void cleanup()
public Object currentActivity()
currentActivity
in interface HjRuntime
public void runKernel(HjSuspendable suspendable)
protected void awaitLatch(ModCountDownLatch inFlightTaskCounter1)
public void scheduleActivity(Runnable runnable)
Runnable
instance.scheduleActivity
in interface HjRuntime
runnable
- The runnable activity to schedule.public void scheduleActivity(HjPlace hjPlace, Runnable runnable)
Runnable
instance.scheduleActivity
in interface HjRuntime
hjPlace
- The place at which to schedule this activity.runnable
- The runnable activity to schedule.public int numWorkerThreads()
numWorkerThreads
in interface HjRuntime
public HjPlace currentPlace()
currentPlace
in interface HjRuntime
public void finish(HjSuspendable suspendable) throws SuspendableException
finish
in interface HjRuntime
suspendable
- The body of the code to run wrapped in a finish block.SuspendableException
public void asyncSeqAt(boolean sequentialize, HjPlace place, HjRunnable runnable)
asyncSeqAt
in interface HjRuntime
sequentialize
- The flag that determines whether the runtime should consider running the body
asynchronously.place
- The place where the async task should run. This parameter may be ignored if the task is to
be run sequentially.runnable
- The body of the code to run, possibly asynchronously.public void asyncSuspAt(HjPlace place, HjSuspendable suspendable)
asyncSuspAt
in interface HjRuntime
place
- The place where the async task should run. This parameter may be ignored if the task is to be
run sequentially.suspendable
- The body of the code to run, possibly asynchronously. The body of the code possibly contains a
suspendable condition.public <V> HjFuture<V> futureSeq(boolean sequentialize, HjCallable<V> callable)
futureSeq
in interface HjRuntime
V
- The return type of the body.sequentialize
- The flag that determines whether the runtime should consider running the body
asynchronously.callable
- The body of the callable to run, possibly asynchronously.public <V> HjFuture<V> futureSusp(HjSuspendingCallable<V> callable)
futureSusp
in interface HjRuntime
V
- The return type of the body.callable
- The body of the callable to run, possibly asynchronously.public <T,V> HjFuture<V> futureAwait(List<HjFuture<T>> dependencies, HjCallable<V> callable)
HjRuntime.asyncAwait(java.util.List, HjRunnable)
which returns a futureNb.futureAwait
in interface HjRuntime
V
- The return type of the body.dependencies
- The data dependencies of the asynchronous taskcallable
- The body of the callable to run, possibly asynchronously.public <T,V> HjFuture<V> futureSuspAwait(List<HjFuture<T>> dependencies, HjSuspendingCallable<V> callable)
HjRuntime
HjRuntime.asyncAwait(java.util.List, HjRunnable)
which returns a future.futureSuspAwait
in interface HjRuntime
V
- The return type of the body.dependencies
- The data dependencies of the asynchronous taskcallable
- The body of the callable to run, possibly asynchronously.public <V> HjDataDrivenFuture<V> newDataDrivenFuture(boolean allowDuplicatePuts)
newDataDrivenFuture
in interface HjRuntime
V
- The type of the data wrapped in the DDF.public <T> void asyncAwait(List<HjFuture<T>> dependences, HjRunnable runnable)
asyncAwait
in interface HjRuntime
dependences
- The data dependencies of the asynchronous taskrunnable
- The body of the code to run, possibly asynchronously.public <T> void asyncSuspAwait(List<HjFuture<T>> dependences, HjSuspendable suspendable)
HjRuntime
asyncSuspAwait
in interface HjRuntime
dependences
- The data dependencies of the asynchronous tasksuspendable
- The body of the code to run, possibly asynchronously.public void isolated(HjRunnable runnable)
isolated.
public void isolated(Object participant, HjRunnable runnable)
public void isolated(Object[] participants, HjRunnable runnable)
public <V> V isolatedWithReturn(HjCallable<V> callable)
isolatedWithReturn.
isolatedWithReturn
in interface HjRuntime
V
- a V object.callable
- The body of the code to run using weak isolation.public <V> V isolatedWithReturn(Object participant, HjCallable<V> callable)
isolatedWithReturn.
isolatedWithReturn
in interface HjRuntime
V
- a V object.participant
- The object involved in the atomic block.callable
- The body of the code to run using weak isolation.public <V> V isolatedWithReturn(Object[] participants, HjCallable<V> callable)
isolatedWithReturn.
isolatedWithReturn
in interface HjRuntime
V
- a V object.participants
- The objects involved in the atomic block.callable
- The body of the code to run using weak isolation.public HjFinishAccumulator newFinishAccumulator(HjOperator ope, Class type)
newFinishAccumulator.
newFinishAccumulator
in interface HjRuntime
ope
- The type of the HjOperatortype
- The result typepublic void finish(List<HjFinishAccumulator> accumulators, HjSuspendable suspendable) throws SuspendableException
finish.
finish
in interface HjRuntime
accumulators
- The accumulators registered on the finish.suspendable
- The body of the code to run wrapped in a finish block.SuspendableException
public HjPhaser newPhaser(HjPhaserMode phaserMode, int busyWaitLimit)
public HjEventLogger retrieveEventLogger()
HjEventLogger
used by the runtime.retrieveEventLogger
in interface HjRuntime
HjEventLogger
used by the runtime.public void asyncPhased(List<HjPhaserPair> phaserList, HjSuspendable suspendable)
asyncPhased.
asyncPhased
in interface HjRuntime
phaserList
- The list of phasers the async is registered on.suspendable
- The body of the code to run, possibly asynchronously.public void next() throws SuspendableException
next
in interface HjRuntime
SuspendableException
public void signal()
public void doWait() throws SuspendableException
doWait
in interface HjRuntime
SuspendableException
public void emergencyShutdown(Throwable cause)
emergencyShutdown
in interface HjRuntime
cause
- The exception causing the shutdown.public void doWork(long n)
public HjMetrics abstractMetrics()
abstractMetrics.
abstractMetrics
in interface HjRuntime
public void dumpEventLog(PrintStream printStream)
dumpEventLog
in interface HjRuntime
printStream
- The stream to use while dumping the events.public void asyncWhen(HjExpression.HjAwaitExpression expression, HjRunnable runnable)
HjFuture
handles.
The body of this async is only executed when the expression evaluates to true, the expression can only be safely evaluated after all the futures involved in the expression have been resolved when in strict mode (expression contains a NOT). There is also a short-circuit mode (expression contains only AND and OR) where the expression is evaluated early and the asynchronous computation triggered even when some of the other dependent tasks may not yet have completed execution.
The semantics of
asyncWhen(awaitExpr, () -> S1)
are as follows:
async(() -> {
boolean exprVal = expr.evaluate();
if (exprVal) {
S1;
}
});
public <V> HjFuture<V> futureWhen(HjExpression.HjAwaitExpression expression, HjCallable<V> callable)
HjFuture
handles. Also returns the
futureNb object representing the value of the computation.
The body of this async is only executed when the expression evaluates to true, the expression can only be safely evaluated after all the futures involved in the expression have been resolved when in strict mode (expression contains a NOT). There is also a short-circuit mode (expression contains only AND and OR) where the expression is evaluated early and the asynchronous computation triggered even when some of the other dependent tasks may not yet have completed execution.
The semantics of
futureWhen(awaitExpr, () -> S1)
are as follows:
futureNb(() -> {
boolean exprVal = expr.evaluate();
if (exprVal) {
S1;
} else {
throw new RuntimeException("clause failed!");
}
});
futureWhen
in interface HjRuntime
expression
- The expression that controls when the async is ready for execution.callable
- The body of the async.public void finish(HjEureka<?,?,?> hjEureka, HjSuspendable suspendable) throws SuspendableException
finish
in interface HjRuntime
hjEureka
- the eureka to be registeredsuspendable
- the body of the finish scopeSuspendableException
public <T> HjSearchEureka<T> newSearchEureka(T initialValue)
HjSearchEureka
instance.newSearchEureka
in interface HjRuntime
initialValue
- The initial value of the search eureka objectHjSearchEureka
instancepublic <T> HjExtremaEureka<T> newExtremaEureka(T initialValue, Comparator<T> comparator, boolean shouldAbortOnOffer)
HjExtremaEureka
instance.newExtremaEureka
in interface HjRuntime
initialValue
- The initial value of the extrema, it should be smaller than expected result.comparator
- The comparator used to maximize the extrema value. The first argument of the comparator
is the existing value in the eureka, and the second argument is the new argument passed
inside the call to offer
and check
.shouldAbortOnOffer
- Whether a successful offer should abort the current taskHjExtremaEureka
instance.public <T> HjConvergenceEureka<T> newConvergenceEureka(T initialValue, java.util.function.BiPredicate<T,T> checker, HjProcedure<T> convergenceCallback)
HjConvergenceEureka
instance.newConvergenceEureka
in interface HjRuntime
initialValue
- The initial value of the eureka.checker
- The predicate used to check for convergence.convergenceCallback
- A callback invoked once the eureka has converged.HjConvergenceEureka
instance.public HjFastBarrierEureka newFastBarrierEureka(int numPhases)
HjFastBarrierEureka
instance.newFastBarrierEureka
in interface HjRuntime
numPhases
- The number of phases in the fast barrier.HjFastBarrierEureka
instance.public <T> HjCountEureka<T> newCountEureka(long numPhases, int spaceForResult)
HjCountEureka
instance.newCountEureka
in interface HjRuntime
numPhases
- spaceForResult
- HjCountEureka
instance.public <T> HjVersionEureka<T> newVersionEureka(int n)
HjVersionEureka
instance.newVersionEureka
in interface HjRuntime
n
- The number of items that need to match before the eureka is resolved.HjVersionEureka
instance.HjRuntime.newVersionEureka(int)
public <T> HjEngineEureka<T> newEngineEureka(int maxUnits)
HjEngineEureka
instance.newEngineEureka
in interface HjRuntime
maxUnits
- The maximum number of time units in the eureka.HjEngineEureka
instance.public <T> HjTimerEureka<T> newTimerEureka(int timeUnitsInMillis)
HjTimerEureka
instance.newTimerEureka
in interface HjRuntime
timeUnitsInMillis
- The maximum number of milliseconds before the eureka is considered resolved.HjTimerEureka
instance.public <L,R> HjBinaryEureka<L,R> newBinaryEureka(HjLogicalOperator operator, HjEureka<L,Object,L> leftEureka, HjEureka<R,Object,R> rightEureka)
HjBinaryEureka
instance.newBinaryEureka
in interface HjRuntime
operator
- The maximum number of milliseconds before the eureka is considered resolved.leftEureka
- The left eureka instance.rightEureka
- The right eureka instance.HjTimerEureka
instance.public <T> HjEureka<T,T,T> retrieveEureka()
retrieveEureka
in interface HjRuntime
T
- The type of value stored in the Eurekapublic <T> void offerEureka(T eurekaValue) throws SuspendableException
offerEureka
in interface HjRuntime
T
- The type of value stored in the EurekaeurekaValue
- The value to be associated with the eurekaSuspendableException
public <T> void checkEureka(T eurekaValue) throws SuspendableException
checkEureka
in interface HjRuntime
T
- The type of value stored in the EurekaeurekaValue
- The value to be associated with the eurekaSuspendableException
public <T> T readEureka()
readEureka
in interface HjRuntime
T
- The type of value stored in the Eurekapublic void abort() throws SuspendableException
abort
in interface HjRuntime
SuspendableException
public void asyncSimt(long estimatedWorkInMilliseconds, int maxParallelism, int start, int end, HjSuspendingProcedureInt2D runnable)
asyncSimt
asyncSimt
in interface HjRuntime
estimatedWorkInMilliseconds
- Amount of sequential work in ms estimated for this taskmaxParallelism
- Amount of parallelism present in the task (assumes linear speedup)start
- Start of range of iterationsend
- End of range of iterationsrunnable
- Body of the asyncpublic HjEventCount newEventCount(int initialCount)
newEventCount
in interface HjRuntime
Copyright © 2015 Rice University - Department of Computer Science. All rights reserved.