public interface HjRuntime
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. |
<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
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
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 maxCount,
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.
|
void initialize()
void cleanup()
void runKernel(HjSuspendable suspendable)
suspendable
- The body of the kernelObject currentActivity()
void scheduleActivity(Runnable runnable)
Runnable
instance.runnable
- The runnable activity to schedule.void scheduleActivity(HjPlace hjPlace, Runnable runnable)
Runnable
instance.hjPlace
- The place at which to schedule this activity.runnable
- The runnable activity to schedule.int numWorkerThreads()
HjPlace currentPlace()
void finish(HjSuspendable suspendable) throws SuspendableException
suspendable
- The body of the code to run wrapped in a finish block.SuspendableException
void asyncSeqAt(boolean sequentialize, HjPlace place, HjRunnable runnable)
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.void asyncSuspAt(HjPlace place, HjSuspendable suspendable)
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.<V> HjFuture<V> futureSeq(boolean sequentialize, HjCallable<V> callable)
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.<V> HjFuture<V> futureSusp(HjSuspendingCallable<V> callable)
V
- The return type of the body.callable
- The body of the callable to run, possibly asynchronously.<T,V> HjFuture<V> futureAwait(List<HjFuture<T>> dependencies, HjCallable<V> callable)
asyncAwait(java.util.List, HjRunnable)
which returns a futureNb.V
- The return type of the body.dependencies
- The data dependencies of the asynchronous taskcallable
- The body of the callable to run, possibly asynchronously.<T,V> HjFuture<V> futureSuspAwait(List<HjFuture<T>> dependencies, HjSuspendingCallable<V> callable)
asyncAwait(java.util.List, HjRunnable)
which returns a future.V
- The return type of the body.dependencies
- The data dependencies of the asynchronous taskcallable
- The body of the callable to run, possibly asynchronously.<V> HjDataDrivenFuture<V> newDataDrivenFuture(boolean allowDuplicatePuts)
V
- The type of the data wrapped in the DDF.<T> void asyncAwait(List<HjFuture<T>> dependences, HjRunnable runnable)
dependences
- The data dependencies of the asynchronous taskrunnable
- The body of the code to run, possibly asynchronously.<T> void asyncSuspAwait(List<HjFuture<T>> dependences, HjSuspendable suspendable)
dependences
- The data dependencies of the asynchronous tasksuspendable
- The body of the code to run, possibly asynchronously.void isolated(HjRunnable runnable)
isolated.
runnable
- The body of the code to run using weak isolation.void isolated(Object participant, HjRunnable runnable)
participant
- The object involved in the atomic block.runnable
- The body of the code to run using weak isolation.void isolated(Object[] participants, HjRunnable runnable)
participants
- The objects involved in the atomic block.runnable
- The body of the code to run using weak isolation.<V> V isolatedWithReturn(HjCallable<V> callable)
isolatedWithReturn.
V
- a V object.callable
- The body of the code to run using weak isolation.<V> V isolatedWithReturn(Object participant, HjCallable<V> callable)
isolatedWithReturn.
V
- a V object.participant
- The object involved in the atomic block.callable
- The body of the code to run using weak isolation.<V> V isolatedWithReturn(Object[] participants, HjCallable<V> callable)
isolatedWithReturn.
V
- a V object.participants
- The objects involved in the atomic block.callable
- The body of the code to run using weak isolation.Object readMode(Object wrappee)
readMode.
wrappee
- The Object whose mode to controlObject writeMode(Object wrappee)
writeMode.
wrappee
- The Object whose mode to controlHjFinishAccumulator newFinishAccumulator(HjOperator ope, Class type)
newFinishAccumulator.
ope
- The type of the HjOperatortype
- The result typevoid finish(List<HjFinishAccumulator> accumulators, HjSuspendable suspendable) throws SuspendableException
finish.
accumulators
- The accumulators registered on the finish.suspendable
- The body of the code to run wrapped in a finish block.SuspendableException
HjPhaser newPhaser(HjPhaserMode phaserMode, int busyWaitLimit)
phaserMode
- The phaser registration mode.busyWaitLimit
- The number of times to iterate in a busy wait loop before blockingvoid asyncPhased(List<HjPhaserPair> phaserList, HjSuspendable suspendable)
asyncPhased.
phaserList
- The list of phasers the async is registered on.suspendable
- The body of the code to run, possibly asynchronously.void next() throws SuspendableException
SuspendableException
void signal()
void doWait() throws SuspendableException
SuspendableException
void emergencyShutdown(Throwable cause)
cause
- The exception causing the shutdown.void doWork(long n)
n
- units of work doneHjMetrics abstractMetrics()
abstractMetrics.
HjEventLogger retrieveEventLogger()
HjEventLogger
used by the runtime.HjEventLogger
used by the runtime.void dumpEventLog(PrintStream printStream)
printStream
- The stream to use while dumping the events.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;
}
});
expression
- The expression that controls when the async is ready for execution.runnable
- The body of the async.<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!");
}
});
expression
- The expression that controls when the async is ready for execution.callable
- The body of the async.void finish(HjEureka<?,?,?> hjEureka, HjSuspendable suspendable) throws SuspendableException
hjEureka
- the eureka to be registeredsuspendable
- the body of the finish scopeSuspendableException
<T> HjSearchEureka<T> newSearchEureka(T initialValue)
HjSearchEureka
instance.initialValue
- The initial value of the search eureka objectHjSearchEureka
instance<T> HjExtremaEureka<T> newExtremaEureka(T initialValue, Comparator<T> comparator, boolean shouldAbortOnOffer)
HjExtremaEureka
instance.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.<T> HjConvergenceEureka<T> newConvergenceEureka(T initialValue, java.util.function.BiPredicate<T,T> checker, HjProcedure<T> convergenceCallback)
HjConvergenceEureka
instance.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.HjFastBarrierEureka newFastBarrierEureka(int numPhases)
HjFastBarrierEureka
instance.numPhases
- The number of phases in the fast barrier.HjFastBarrierEureka
instance.<T> HjCountEureka<T> newCountEureka(long maxCount, int spaceForResult)
HjCountEureka
instance.maxCount
- The maximum number of eureka events before the eureka is resolved.spaceForResult
- The maximum number of results to store in the eureka.HjCountEureka
instance.<T> HjVersionEureka<T> newVersionEureka(int n)
HjVersionEureka
instance.n
- The number of items that need to match before the eureka is resolved.HjVersionEureka
instance.newVersionEureka(int)
<T> HjEngineEureka<T> newEngineEureka(int maxUnits)
HjEngineEureka
instance.maxUnits
- The maximum number of time units in the eureka.HjEngineEureka
instance.<T> HjTimerEureka<T> newTimerEureka(int timeUnitsInMillis)
HjTimerEureka
instance.timeUnitsInMillis
- The maximum number of milliseconds before the eureka is considered resolved.HjTimerEureka
instance.<L,R> HjBinaryEureka<L,R> newBinaryEureka(HjLogicalOperator operator, HjEureka<L,Object,L> leftEureka, HjEureka<R,Object,R> rightEureka)
HjBinaryEureka
instance.operator
- The maximum number of milliseconds before the eureka is considered resolved.leftEureka
- The left eureka instance.rightEureka
- The right eureka instance.HjTimerEureka
instance.<T> HjEureka<T,T,T> retrieveEureka()
T
- The type of value stored in the Eureka<T> void offerEureka(T eurekaValue) throws SuspendableException
T
- The type of value stored in the EurekaeurekaValue
- The value to be associated with the eurekaSuspendableException
<T> void checkEureka(T eurekaValue) throws SuspendableException
T
- The type of value stored in the EurekaeurekaValue
- The value to be associated with the eurekaSuspendableException
<T> T readEureka()
T
- The type of value stored in the Eurekavoid abort() throws SuspendableException
SuspendableException
void asyncSimt(long estimatedWorkInMilliseconds, int maxParallelism, int start, int end, HjSuspendingProcedureInt2D runnable)
asyncSimt
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 asyncHjEventCount newEventCount(int initialCount)
Copyright © 2015 Rice University - Department of Computer Science. All rights reserved.