public class Module0 extends Object
Modifier and Type | Field and Description |
---|---|
protected static AtomicBoolean |
runtimeInitialized
Constant
runtimeInitialized |
Modifier | Constructor and Description |
---|---|
protected |
Module0()
Private constructor to disallow instance creation.
|
Modifier and Type | Method and Description |
---|---|
static HjMetrics |
abstractMetrics()
Returns the metrics report for the currently executing task.
|
static void |
asyncNb(HjRunnable runnable)
Creates a new asynchronous task to execute the wrapped statements.
|
static void |
asyncNbAt(HjPlace place,
HjRunnable runnable) |
static <T> void |
asyncNbAwait(HjFuture<T> f1,
HjFuture<T> f2,
HjFuture<T> f3,
HjRunnable runnable)
Construct to create an asynchronous task which is executed when all the futures are resolved.
|
static <T> void |
asyncNbAwait(HjFuture<T> f1,
HjFuture<T> f2,
HjRunnable runnable)
Construct to create an asynchronous task which is executed when both the futures are resolved.
|
static <T> void |
asyncNbAwait(HjFuture<T> f1,
HjRunnable runnable)
Construct to create an asynchronous task which is executed when the futureNb is resolved.
|
static <T> void |
asyncNbAwait(List<HjFuture<T>> dependences,
HjRunnable runnable)
Construct to create an asynchronous task which is executed when all the futureNb are resolved.
|
static void |
asyncNbSeq(boolean sequentialize,
HjRunnable runnable)
Similar to the regular
asyncNb(edu.rice.hj.api.HjRunnable) except that the boolean
condition is used as a tuning parameter to determine if the async should just be executed sequentially (when the
condition is true) in the parent task. |
static void |
asyncNbSeq(boolean sequentialize,
HjRunnable seqRunnable,
HjRunnable parRunnable)
Similar to the regular
asyncNb(edu.rice.hj.api.HjRunnable) except that the boolean
condition is used as a tuning parameter to determine if the async should just be executed sequentially (when the
condition is true) in the parent task. |
static void |
asyncPhased(HjPhaserPair phaserPair1,
HjPhaserPair phaserPair2,
HjSuspendable suspendable)
Create an asynchronous task phased on a specified subset of its parent’s phasers with specified modes (e.g.,
phaser ph1 with mode1), or on the entire set of the parent's phasers and modes (by default, if no subset is
specified).
|
static void |
asyncPhased(HjPhaserPair phaserPair,
HjSuspendable suspendable)
Create an asynchronous task phased on a specified subset of its parent’s phasers with specified modes (e.g.,
phaser ph1 with mode1), or on the entire set of the parent's phasers and modes (by default, if no subset is
specified).
|
static void |
asyncPhased(List<HjPhaserPair> phaserList,
HjSuspendable suspendable)
Create an asynchronous task phased on a specified subset of its parent’s phasers with specified modes (e.g.,
phaser ph1 with mode1), or on the entire set of the parent's phasers and modes (by default, if no subset is
specified).
|
protected static int |
computeDefaultChunkSize(int startInc,
int endInc)
Computes the chunk size based on the number of iterations and the number of worker threads.
|
static void |
doWait()
wait on each phaser that task is registered on with a wait capability (WAIT, SIG_WAIT). wait is a potentially
blocking operation.
|
static void |
doWork(long n)
Used by abstract performance metrics to report work done by the currently executing task.
|
static void |
dumpEventLog(PrintStream printStream)
Dumps the events tracked by the runtime.
|
static void |
emergencyShutdown(Throwable cause)
Immediately exit the program due to an execution error.
|
static void |
finalizeHabanero()
Cleans up all Habanero-Java state.
|
static void |
finish(HjFinishAccumulator f1,
HjFinishAccumulator f2,
HjFinishAccumulator f3,
HjSuspendable suspendable)
finish.
|
static void |
finish(HjFinishAccumulator f1,
HjFinishAccumulator f2,
HjSuspendable suspendable)
finish.
|
static void |
finish(HjFinishAccumulator f1,
HjSuspendable suspendable)
finish.
|
static void |
finish(HjSuspendable suspendable)
Creates a new finish scope to execute the wrapped statements.
|
static void |
finish(List<HjFinishAccumulator> accumulators,
HjSuspendable suspendable)
finish.
|
static void |
forallNb(HjRegion.HjRegion1D hjRegion,
HjProcedureInt1D body)
Construct to represent loop-level parallelism.
|
static void |
forallNb(HjRegion.HjRegion2D hjRegion,
HjProcedureInt2D body)
Construct to represent loop-level parallelism.
|
static void |
forallNb(HjRegion.HjRegion3D hjRegion,
HjProcedureInt3D body)
Construct to represent loop-level parallelism.
|
static void |
forallNb(int startInc,
int endInc,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism.
|
static void |
forallNb(int s0,
int e0,
int s1,
int e1,
HjProcedureInt2D body)
Construct to represent loop-level parallelism.
|
static <T> void |
forallNb(Iterable<T> iterable,
HjProcedure<T> body)
Construct to represent loop-level parallelism.
|
static void |
forallNbChunked(HjRegion.HjRegion1D hjRegion,
HjProcedureInt1D body)
Construct to represent loop-level parallelism using chunking/grouping.
|
static void |
forallNbChunked(HjRegion.HjRegion2D hjRegion,
HjProcedureInt2D body)
Construct to represent loop-level parallelism using chunking/grouping.
|
static void |
forallNbChunked(HjRegion.HjRegion3D hjRegion,
HjProcedureInt3D body)
Construct to represent loop-level parallelism using chunking/grouping.
|
static void |
forallNbChunked(int startInc,
int endInc,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism using chunking/grouping.
|
static void |
forallNbChunked(int startInc,
int endInc,
int chunkSize,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism using chunking/grouping.
|
static void |
forallNbChunked(int s0,
int e0,
int s1,
int e1,
HjProcedureInt2D body)
Construct to represent loop-level parallelism using chunking/grouping.
|
static void |
forallPhased(int startInc,
int endInc,
HjSuspendingProcedure<Integer> body)
In forallPhased, you have a phaser registered with the spawned asyncs (there is one async for each iteration of
the loop) implicitly.
|
static <T> void |
forallPhased(Iterable<T> iterable,
HjSuspendingProcedure<T> body)
In forallPhased, you have a phaser registered with the spawned asyncs (there is one async for each iteration of
the loop) implicitly.
|
static void |
forasync(HjRegion.HjRegion1D hjRegion,
HjProcedureInt1D body)
Construct to represent loop-level parallelism.
|
static void |
forasyncChunked(HjRegion.HjRegion1D hjRegion,
HjProcedureInt1D body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNb(HjRegion.HjRegion2D hjRegion,
HjProcedureInt2D body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNb(HjRegion.HjRegion3D hjRegion,
HjProcedureInt3D body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNb(int startInc,
int endInc,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNb(int s0,
int e0,
int s1,
int e1,
HjProcedureInt2D body)
Construct to represent loop-level parallelism.
|
static <T> void |
forasyncNb(Iterable<T> iterable,
HjProcedure<T> body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNbChunked(HjRegion.HjRegion2D hjRegion,
HjProcedureInt2D body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNbChunked(HjRegion.HjRegion3D hjRegion,
HjProcedureInt3D body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNbChunked(int startInc,
int endInc,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism.
|
static void |
forasyncNbChunked(int startInc,
int endInc,
int chunkSize,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism.
|
static void |
forasyncPhased(int startInc,
int endInc,
HjSuspendingProcedure<Integer> body)
In forasyncPhased, you have a phaser registered with the spawned asyncs (there is one async for each iteration of
the loop) implicitly.
|
static void |
forasyncPhased(int startInc,
int endInc,
List<HjPhaserPair> phaserList,
HjSuspendingProcedure<Integer> body)
In this variant of forasyncPhased, you have phasers registered with the spawned asyncs (there is one async for
each iteration of the loop) explicitly.
|
static <T> void |
forasyncPhased(Iterable<T> iterable,
List<HjPhaserPair> phaserList,
HjSuspendingProcedure<T> body)
In this variant of forasyncPhased, you have phasers registered with the spawned asyncs (there is one async for
each iteration of the loop) explicitly.
|
static void |
forseqNb(HjRegion.HjRegion1D hjRegion,
HjProcedureInt1D body)
Construct to represent a sequential loop while working with regions.
|
static void |
forseqNb(HjRegion.HjRegion2D hjRegion,
HjProcedureInt2D body)
Construct to represent a sequential loop while working with regions.
|
static void |
forseqNb(HjRegion.HjRegion3D hjRegion,
HjProcedureInt3D body)
Construct to represent a sequential loop while working with regions.
|
static void |
forseqNb(int startInc,
int endInc,
HjProcedure<Integer> body)
Construct to represent loop-level parallelism.
|
static void |
forseqNb(int s0,
int e0,
int s1,
int e1,
HjProcedureInt2D body)
Construct to represent loop-level parallelism.
|
static <T> void |
forseqNb(Iterable<T> iterable,
HjProcedure<T> body)
Construct to represent loop-level parallelism.
|
static <V> HjFuture<V> |
futureNb(HjCallable<V> callable)
Construct to create an asynchronous task that returns a result which will be available in the futureNb.
|
static <T,V> HjFuture<V> |
futureNbAwait(HjFuture<T> f1,
HjCallable<V> callable)
futureNbAwait.
|
static <T,V> HjFuture<V> |
futureNbAwait(HjFuture<T> f1,
HjFuture<T> f2,
HjCallable<V> callable)
futureNbAwait.
|
static <T,V> HjFuture<V> |
futureNbAwait(HjFuture<T> f1,
HjFuture<T> f2,
HjFuture<T> f3,
HjCallable<V> callable)
futureNbAwait.
|
static <T,V> HjFuture<V> |
futureNbAwait(List<HjFuture<T>> dependences,
HjCallable<V> callable)
futureNbAwait.
|
static <V> HjFuture<V> |
futureNbSeq(boolean sequentialize,
HjCallable<V> callable)
Construct to create an asynchronous task that returns a result which will be available in the future.
|
static <V> HjFuture<V> |
futureNbSeq(boolean sequentialize,
HjCallable<V> seqCallable,
HjCallable<V> parCallable)
Similar to the regular
futureNb(edu.rice.hj.api.HjCallable) except that the boolean
condition is used as a tuning parameter to determine if the future should just be executed sequentially (when the
condition is true) in the parent task. |
static List<HjRegion.HjRegion1D> |
group(HjRegion.HjRegion1D hjRegion,
int processorGrid)
Evenly divides the loop iteration space into
processorGrid chunks. |
static List<HjRegion.HjRegion2D> |
group(HjRegion.HjRegion2D hjRegion,
int processorGrid0,
int processorGrid1)
Evenly divides the loop iteration space into
processorGrid0 x processorGrid1 chunks. |
static HjPlace |
here() |
static void |
initializeHabanero()
Initialize the Habanero-Java execution environment.
|
static void |
launchHabaneroApp(HjSuspendable suspendable)
Launches the fragment of code to be run by the habanero runtime.
|
static void |
launchHabaneroApp(HjSuspendable suspendable,
Runnable preFinalizeCallback)
Launches the fragment of code to be run by the habanero runtime.
|
static HjRegion.HjRegion1D |
myGroup(int groupId,
HjRegion.HjRegion1D hjRegion,
int groupSize)
Retrieves the region represented for the given
groupId when the iteration space is divided into groupSize groups. |
static RectangularRegion2D |
myGroup(int groupId0,
int groupId1,
HjRegion.HjRegion2D hjRegion,
int groupSize0,
int groupSize1)
Retrieves the region represented for the given
(groupId0, groupId1) when the iteration space is divided
into groupSize0 x groupSize1 groups. |
static <V> HjDataDrivenFuture<V> |
newDataDrivenFuture()
Factory method to create a DataDrivenFuture instance.
|
static <V> HjDataDrivenFuture<V> |
newDataDrivenFuture(boolean allowDuplicatePuts)
Factory method to create a DataDrivenFuture instance.
|
static <V> HjDataDrivenFuture<V> |
newDDF()
Factory method to create a DataDrivenFuture instance.
|
static <V> HjDataDrivenFuture<V> |
newDDF(boolean allowDuplicates)
Factory method to create a DataDrivenFuture instance.
|
static HjFinishAccumulator |
newFinishAccumulator(HjOperator ope,
Class type)
Factory method to create a HjFinishAccumulator object.
|
static HjPhaser |
newPhaser(HjPhaserMode phaserMode)
Factory method to create a new
HjPhaser with the specified mode. |
static HjPhaser |
newPhaser(HjPhaserMode phaserMode,
int busyWaitLimit)
Factory method to create a new
HjPhaser with the specified mode. |
static HjPoint |
newPoint(int... values)
Factory method to create new HjPoint instances.
|
static HjRegion.HjRegion1D |
newRectangularRegion1D(int pMinInc,
int pMaxInc)
Factory method to create a 1D rectangular region object.
|
static HjRegion.HjRegion2D |
newRectangularRegion2D(int pMinInc0,
int pMaxInc0,
int pMinInc1,
int pMaxInc1)
Factory method to create a 2D rectangular region object.
|
static HjRegion.HjRegion3D |
newRectangularRegion3D(int pMinInc0,
int pMaxInc0,
int pMinInc1,
int pMaxInc1,
int pMinInc2,
int pMaxInc2)
Factory method to create a 3D rectangular region object.
|
static void |
next()
Advance each phaser that this task is registered on to its next phase, in accordance with this task's
registration mode.
|
static int |
numPlaces() |
static int |
numWorkerThreads()
Return the number of worker threads employed by the runtime.
|
static HjPlace |
place(int id) |
static void |
printBuildInfo(PrintStream outputStream)
Prints the String representing of the build information.
|
static void |
signal()
signal each phaser that task is registered on with a signal capability (SIG, SIG_WAIT, SIGNAL). signal is a
non-blocking operation - computation between signal and next serves as a 'split phase barrier'
|
static boolean[] |
waitAll(HjFuture[] futures)
Blocks until all of the operations associated with the active requests in the array have completed.
|
static boolean[] |
waitAny(HjFuture[] futures)
Blocks until one of the operations associated with the active requests in the array has completed successfully.
|
protected static AtomicBoolean runtimeInitialized
runtimeInitialized
public static void printBuildInfo(PrintStream outputStream)
public static void launchHabaneroApp(HjSuspendable suspendable)
public static void launchHabaneroApp(HjSuspendable suspendable, Runnable preFinalizeCallback)
public static void finish(HjSuspendable suspendable) throws SuspendableException
Usage:
finish(() -> S1);
OR
finish(() -> {S1; S2;...});
Execute statements S1, S2, ..., but wait until all (transitively) spawned asyncs and futures enclosed in the statements scope have terminated. Also, propagate a list of all exceptions thrown by asyncs spawned within statements's scope.
suspendable
- a HjSuspendable
object.SuspendableException
HjRuntime.finish(edu.rice.hj.api.HjSuspendable)
public static void initializeHabanero()
public static void finalizeHabanero()
public static void emergencyShutdown(Throwable cause)
cause
- a Throwable
object.HjRuntime.emergencyShutdown(Throwable)
public static int numWorkerThreads()
final int numThreads = numWorkerThreads();
HjRuntime.numWorkerThreads()
public static void asyncNb(HjRunnable runnable)
Usage:
HjRunnable aRunnable = () -> { S1; };
async(aRunnable);
OR
async(() -> S1);
OR
async(() -> {S1; S2;...});
Spawn a new child task to execute statements S1, S2, ... asynchronously (i.e., before, after, or in parallel)
with the remainder of the parent task.
In general, an HJ program can create an unbounded number of tasks
at runtime.
The HJ runtime system is responsible for scheduling these tasks on a fixed number of
processors.
runnable
- a HjRunnable
object.HjRuntime.asyncSeqAt(boolean, edu.rice.hj.api.HjPlace, edu.rice.hj.api.HjRunnable)
public static void asyncNbSeq(boolean sequentialize, HjRunnable runnable)
asyncNb(edu.rice.hj.api.HjRunnable)
except that the boolean
condition is used as a tuning parameter to determine if the async should just be executed sequentially (when the
condition is true) in the parent task.
asyncNbSeq(cond, () -> S1)
are as follows:
if (cond)
S1;
else
async(() -> S1);
sequentialize
- a boolean.runnable
- a HjRunnable
object.HjRuntime.asyncSeqAt(boolean, edu.rice.hj.api.HjPlace, edu.rice.hj.api.HjRunnable)
public static void asyncNbSeq(boolean sequentialize, HjRunnable seqRunnable, HjRunnable parRunnable)
asyncNb(edu.rice.hj.api.HjRunnable)
except that the boolean
condition is used as a tuning parameter to determine if the async should just be executed sequentially (when the
condition is true) in the parent task.
asyncNbSeq(cond, () -> S1, () -> S2)
are as follows:
if (cond)
S1;
else
async(() -> S2);
sequentialize
- The flag that determines whether the runtime should consider running the body
asynchronously.seqRunnable
- The body of the code to run when sequentialize flag is true.parRunnable
- The body of the code to run when sequentialize flag is false.HjRuntime.asyncSeqAt(boolean, edu.rice.hj.api.HjPlace, edu.rice.hj.api.HjRunnable)
public static <T> void forseqNb(Iterable<T> iterable, HjProcedure<T> body)
The semantics of
forseqNb(iterableOfT, (k) -> S2(k))
are as follows:
for (T k : iterableOfT) {
S2(k);
}
iterable
- a Iterable
object.body
- a HjProcedure
object.public static <T> void forallNb(Iterable<T> iterable, HjProcedure<T> body) throws SuspendableException
The semantics of
forallNb(iterableOfT, (k) -> S2(k))
are as follows:
finish(() -> {
for (T k : iterableOfT) {
final T kk = k;
async(() -> {
S2(kk);
});
}
});
T
- a T object.iterable
- a Iterable
object.body
- a HjProcedure
object.SuspendableException
forasyncNb(Iterable, edu.rice.hj.api.HjProcedure)
public static <T> void forasyncNb(Iterable<T> iterable, HjProcedure<T> body)
The semantics of
forasyncNb(iterableOfT, (k) -> S2(k))
are as follows:
for (T k : iterableOfT) {
final T kk = k;
async(() -> {
S2(kk);
});
}
T
- a T object.iterable
- a Iterable
object.body
- a HjProcedure
object.public static void forseqNb(int startInc, int endInc, HjProcedure<Integer> body)
The semantics of
forseqNb(startInc, endInc, (k) -> S2(k))
are as follows:
for (int k = startInc; k <= endInc; k++) {
S2(k);
}
startInc
- a int.endInc
- a int.body
- a HjProcedure
object.forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static HjRegion.HjRegion1D newRectangularRegion1D(int pMinInc, int pMaxInc)
pMinInc
- a int.pMaxInc
- a int.HjRegion.HjRegion1D
object.RegionFactory.newRectangularRegion1D(int, int)
public static void forallNb(int startInc, int endInc, HjProcedure<Integer> body) throws SuspendableException
The semantics of
forallNb(startInc, endInc, (k) -> S2(k))
are as follows:
finish(() -> {
for (int k = startInc; k <= endInc; k++) {
final int kk = k;
async(() -> {
S2(kk);
});
}
});
startInc
- a int.endInc
- a int.body
- a HjProcedure
object.SuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncNb(int startInc, int endInc, HjProcedure<Integer> body)
The semantics of
forasyncNb(startInc, endInc, (k) -> S2(k))
are as follows:
for (int k = startInc; k <= endInc; k++) {
final int kk = k;
async(() -> {
S2(kk);
});
}
startInc
- a int.endInc
- a int.body
- a HjProcedure
object.public static void forallNbChunked(int startInc, int endInc, HjProcedure<Integer> body) throws SuspendableException
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
refer to forallNb(int, int, edu.rice.hj.api.HjProcedure)
, forallNbChunked(int, int, int, edu.rice.hj.api.HjProcedure)
, and forasyncNbChunked(int, int, int, edu.rice.hj.api.HjProcedure)
startInc
- a int.endInc
- a int.body
- a HjProcedure
object.SuspendableException
protected static int computeDefaultChunkSize(int startInc, int endInc)
public static void forallNbChunked(int startInc, int endInc, int chunkSize, HjProcedure<Integer> body) throws SuspendableException
In this variant, the user has control over the chunk size used and hence the number of tasks created for the loop.
refer to forallNb(int, int, edu.rice.hj.api.HjProcedure)
and forasyncNbChunked(int, int, int, edu.rice.hj.api.HjProcedure)
startInc
- a int.endInc
- a int.chunkSize
- a int.body
- a HjProcedure
object.SuspendableException
public static void forasyncNbChunked(int startInc, int endInc, int chunkSize, HjProcedure<Integer> body)
In this variant, the user has control over the chunk size used and hence the number of tasks created for the loop.
startInc
- a int.endInc
- a int.chunkSize
- a int.body
- a HjProcedure
object.public static void forasyncNbChunked(int startInc, int endInc, HjProcedure<Integer> body)
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
startInc
- a int.endInc
- a int.body
- a HjProcedure
object.forasyncNbChunked(int, int, int, edu.rice.hj.api.HjProcedure)
public static <V> HjFuture<V> futureNb(HjCallable<V> callable)
HjCallable aCallable = () -> { return S1; };
HjFuture aFuture = futureNb(aRunnable);
OR
HjFuture aFuture = futureNb(() -> { return S1; });
Support for async tasks with return values. aFuture
contains a "futureNb handle" to the newly created
task and the operation aFuture.get()
(also known as a force operation) can be performed to obtain the
result of the futureNb task.
The futureNb task executes statement S1 asynchronously (i.e., before, after,
or in parallel) with the remainder of the parent task.
In general, an HJ program can create an unbounded
number of futures at runtime.
The HJ runtime system is responsible for scheduling these futureNb tasks on
a fixed number of processors.
V
- a V object.callable
- a HjCallable
object.HjFuture
object.HjRuntime.futureSeq(boolean, edu.rice.hj.api.HjCallable)
public static <V> HjFuture<V> futureNbSeq(boolean sequentialize, HjCallable<V> callable)
futureNb(edu.rice.hj.api.HjCallable)
except that the boolean condition is
used as a tuning parameter to determine if the future should just be executed sequentially (when the condition is
true) in the parent task. asyncNbSeq(boolean, edu.rice.hj.api.HjRunnable)
V
- a V object.sequentialize
- a boolean.callable
- a HjCallable
object.HjFuture
object.HjRuntime.futureSeq(boolean, edu.rice.hj.api.HjCallable)
public static <V> HjFuture<V> futureNbSeq(boolean sequentialize, HjCallable<V> seqCallable, HjCallable<V> parCallable)
futureNb(edu.rice.hj.api.HjCallable)
except that the boolean
condition is used as a tuning parameter to determine if the future should just be executed sequentially (when the
condition is true) in the parent task. asyncNbSeq(boolean,
edu.rice.hj.api.HjRunnable, edu.rice.hj.api.HjRunnable)
V
- a V object.sequentialize
- The flag that determines whether the runtime should consider running the body
asynchronously.seqCallable
- The body of the code to run when sequentialize flag is true.parCallable
- The body of the code to run when sequentialize flag is false.HjFuture
object.HjRuntime.futureSeq(boolean, edu.rice.hj.api.HjCallable)
public static <V> HjDataDrivenFuture<V> newDDF()
V
- a V object.HjDataDrivenFuture
object.HjRuntime.newDataDrivenFuture(boolean)
public static <V> HjDataDrivenFuture<V> newDDF(boolean allowDuplicates)
V
- a V object.HjDataDrivenFuture
object.HjRuntime.newDataDrivenFuture(boolean)
public static <V> HjDataDrivenFuture<V> newDataDrivenFuture()
V
- a V object.HjDataDrivenFuture
object.HjRuntime.newDataDrivenFuture(boolean)
public static <V> HjDataDrivenFuture<V> newDataDrivenFuture(boolean allowDuplicatePuts)
V
- a V object.HjDataDrivenFuture
object.HjRuntime.newDataDrivenFuture(boolean)
public static <T> void asyncNbAwait(HjFuture<T> f1, HjRunnable runnable)
f1
- The futureNb (or DDF) on which to register the callbackrunnable
- The callback to execute asynchronously when the futureNb (or DDF) is resolvedHjRuntime.asyncAwait(java.util.List, edu.rice.hj.api.HjRunnable)
public static <T> void asyncNbAwait(List<HjFuture<T>> dependences, HjRunnable runnable)
dependences
- a List
object.runnable
- a HjRunnable
object.HjRuntime.asyncAwait(java.util.List, edu.rice.hj.api.HjRunnable)
public static <T> void asyncNbAwait(HjFuture<T> f1, HjFuture<T> f2, HjRunnable runnable)
f1
- The futureNb (or DDF) on which to register the callbackf2
- The futureNb (or DDF) on which to register the callbackrunnable
- The callback to execute asynchronously when the both futures (or DDFs) are resolvedHjRuntime.asyncAwait(java.util.List, edu.rice.hj.api.HjRunnable)
public static <T> void asyncNbAwait(HjFuture<T> f1, HjFuture<T> f2, HjFuture<T> f3, HjRunnable runnable)
f1
- The futureNb (or DDF) on which to register the callbackf2
- The futureNb (or DDF) on which to register the callbackf3
- The futureNb (or DDF) on which to register the callbackrunnable
- The callback to execute asynchronously when the all futures (or DDFs) are resolvedHjRuntime.asyncAwait(java.util.List, edu.rice.hj.api.HjRunnable)
public static <T,V> HjFuture<V> futureNbAwait(HjFuture<T> f1, HjCallable<V> callable)
futureNbAwait.
V
- a V object.f1
- a HjFuture
object.callable
- a HjCallable
object.HjFuture
object.HjRuntime.futureAwait(java.util.List, edu.rice.hj.api.HjCallable)
public static <T,V> HjFuture<V> futureNbAwait(List<HjFuture<T>> dependences, HjCallable<V> callable)
futureNbAwait.
V
- a V object.dependences
- a List
object.callable
- a HjCallable
object.HjFuture
object.HjRuntime.futureAwait(java.util.List, edu.rice.hj.api.HjCallable)
public static <T,V> HjFuture<V> futureNbAwait(HjFuture<T> f1, HjFuture<T> f2, HjCallable<V> callable)
futureNbAwait.
V
- a V object.f1
- a HjFuture
object.f2
- a HjFuture
object.callable
- a HjCallable
object.HjFuture
object.HjRuntime.futureAwait(java.util.List, edu.rice.hj.api.HjCallable)
public static <T,V> HjFuture<V> futureNbAwait(HjFuture<T> f1, HjFuture<T> f2, HjFuture<T> f3, HjCallable<V> callable)
futureNbAwait.
V
- a V object.f1
- a HjFuture
object.f2
- a HjFuture
object.f3
- a HjFuture
object.callable
- a HjCallable
object.HjFuture
object.HjRuntime.futureAwait(java.util.List, edu.rice.hj.api.HjCallable)
public static boolean[] waitAll(HjFuture[] futures) throws SuspendableException
waitAll()
is a like a finish scope for all requests in the array. NOTE: This operation blocks the worker
thread!futures
- The input futureNb array, we need to wait on all of them.SuspendableException
public static boolean[] waitAny(HjFuture[] futures)
futures
- The input futureNb array, we need to wait on only one of them.public static HjFinishAccumulator newFinishAccumulator(HjOperator ope, Class type)
ope
- a HjOperator
object.type
- a Class
object.HjFinishAccumulator
object.HjRuntime.newFinishAccumulator(edu.rice.hj.api.HjOperator, Class)
public static void finish(HjFinishAccumulator f1, HjSuspendable suspendable) throws SuspendableException
finish.
f1
- a HjFinishAccumulator
object.suspendable
- a HjSuspendable
object.SuspendableException
HjRuntime.finish(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void finish(List<HjFinishAccumulator> accumulators, HjSuspendable suspendable) throws SuspendableException
finish.
accumulators
- a List
object.suspendable
- a HjSuspendable
object.SuspendableException
HjRuntime.finish(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void finish(HjFinishAccumulator f1, HjFinishAccumulator f2, HjSuspendable suspendable) throws SuspendableException
finish.
f1
- a HjFinishAccumulator
object.f2
- a HjFinishAccumulator
object.suspendable
- a HjSuspendable
object.SuspendableException
HjRuntime.finish(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void finish(HjFinishAccumulator f1, HjFinishAccumulator f2, HjFinishAccumulator f3, HjSuspendable suspendable) throws SuspendableException
finish.
f1
- a HjFinishAccumulator
object.f2
- a HjFinishAccumulator
object.f3
- a HjFinishAccumulator
object.suspendable
- a HjSuspendable
object.SuspendableException
HjRuntime.finish(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void asyncPhased(HjPhaserPair phaserPair, HjSuspendable suspendable)
phaserPair
- a HjPhaserPair
object.suspendable
- a HjSuspendable
object.HjRuntime.asyncPhased(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void asyncPhased(HjPhaserPair phaserPair1, HjPhaserPair phaserPair2, HjSuspendable suspendable)
phaserPair1
- a HjPhaserPair
object.phaserPair2
- a HjPhaserPair
object.suspendable
- a HjSuspendable
object.HjRuntime.asyncPhased(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void asyncPhased(List<HjPhaserPair> phaserList, HjSuspendable suspendable)
phaserList
- a List
object.suspendable
- a HjSuspendable
object.HjRuntime.asyncPhased(java.util.List, edu.rice.hj.api.HjSuspendable)
public static void forallPhased(int startInc, int endInc, HjSuspendingProcedure<Integer> body) throws SuspendableException
Example usage:
forallPhased(0, m - 1, (i) -> {
System.out.println("Hello " + i);
next(); // Barrier
System.out.println("Goodbye " + i);
});
Here, all the hellos appear before all the goodbyes.
Please refer to forasyncPhased(int, int, edu.rice.hj.api.HjSuspendingProcedure)
for
additional semantics.
startInc
- a int.endInc
- a int.body
- a HjProcedure
object.SuspendableException
forasyncPhased(int, int, java.util.List, edu.rice.hj.api.HjSuspendingProcedure)
public static HjPhaser newPhaser(HjPhaserMode phaserMode)
HjPhaser
with the specified mode. Scope of phaser is
limited to immediately enclosing finish.phaserMode
- a HjPhaserMode
object.HjPhaser
object.HjRuntime.newPhaser(edu.rice.hj.api.HjPhaserMode, int)
public static void forasyncPhased(int startInc, int endInc, List<HjPhaserPair> phaserList, HjSuspendingProcedure<Integer> body)
Please refer to forasyncPhased(int, int, edu.rice.hj.api.HjSuspendingProcedure)
for
additional semantics.
startInc
- a int.endInc
- a int.phaserList
- a List
object.body
- a HjProcedure
object.forasyncPhased(int, int, java.util.List, edu.rice.hj.api.HjSuspendingProcedure)
public static HjPhaser newPhaser(HjPhaserMode phaserMode, int busyWaitLimit)
HjPhaser
with the specified mode. Scope of phaser is
limited to immediately enclosing finish.phaserMode
- a HjPhaserMode
object.busyWaitLimit
- The busy wait iteration limit.HjPhaser
object.HjRuntime.newPhaser(edu.rice.hj.api.HjPhaserMode, int)
public static <T> void forallPhased(Iterable<T> iterable, HjSuspendingProcedure<T> body) throws SuspendableException
Example usage:
forallPhased(anIterable, (i) -> {
System.out.println("Hello " + i);
next(); // Barrier
System.out.println("Goodbye " + i);
});
Here, all the hellos appear before all the goodbyes.
Please refer to forasyncPhased(int, int, edu.rice.hj.api.HjSuspendingProcedure)
for
additional semantics.
T
- a T object.iterable
- a Iterable
object.body
- a HjProcedure
object.SuspendableException
forasyncPhased(int, int, java.util.List, edu.rice.hj.api.HjSuspendingProcedure)
public static <T> void forasyncPhased(Iterable<T> iterable, List<HjPhaserPair> phaserList, HjSuspendingProcedure<T> body)
Please refer to forasyncPhased(int, int, edu.rice.hj.api.HjSuspendingProcedure)
for
additional semantics.
T
- a T object.iterable
- a Iterable
object.phaserList
- a List
object.body
- a HjProcedure
object.forasyncPhased(Iterable, java.util.List, edu.rice.hj.api.HjSuspendingProcedure)
public static void forasyncPhased(int startInc, int endInc, HjSuspendingProcedure<Integer> body)
The semantics of:
forasyncPhased(0, m - 1, (i) -> { S(i); } );
is equivalent to:
final HjPhaser ph = newPhaser(SIG_WAIT);
for(int ii = 0; ii <= m - 1; ii++) {
final int i = ii;
asyncPhased(ph.inMode(SIG_WAIT), () -> { S(i); });
}
Example usage:
finish(() -> {
forasyncPhased(0, m - 1, (i) -> {
System.out.println("Hello " + i);
next(); // Barrier
System.out.println("Goodbye " + i);
});
});
Here, all the hellos appear before all the goodbyes.startInc
- a int.endInc
- a int.body
- a HjProcedure
object.forasyncPhased(int, int, java.util.List, edu.rice.hj.api.HjSuspendingProcedure)
public static void next() throws SuspendableException
SuspendableException
HjRuntime.next()
public static void signal()
HjRuntime.signal()
public static void doWait() throws SuspendableException
SuspendableException
HjRuntime.doWait()
public static void doWork(long n)
Usage:
finish(() -> {
async(() -> { doWork(1); ... });
doWork(2);
async(() -> { doWork(2); ... });
async(() -> { doWork(3); ... });
});
final HjMetrics actualMetrics = abstractMetrics();
AbstractMetricsManager.dumpStatistics(actualMetrics);
n
- The units of work to recordHjRuntime.doWork(long)
public static HjMetrics abstractMetrics()
Usage:
final HjMetrics actualMetrics = abstractMetrics();
AbstractMetricsManager.dumpStatistics(actualMetrics);
HjRuntime.abstractMetrics()
public static void dumpEventLog(PrintStream printStream)
printStream
- The stream to use while dumping the events.HjRuntime.dumpEventLog(java.io.PrintStream)
public static HjPoint newPoint(int... values)
An example use of creating a point representing the origin in 2D geometry:
final HjPoint origin = newPoint(0, 0);
values
- The individual terms of the point.Point
instance.PointFactory.factory(int...)
public static HjRegion.HjRegion3D newRectangularRegion3D(int pMinInc0, int pMaxInc0, int pMinInc1, int pMaxInc1, int pMinInc2, int pMaxInc2)
pMinInc0
- a int.pMaxInc0
- a int.pMinInc1
- a int.pMaxInc1
- a int.pMinInc2
- a int.pMaxInc2
- a int.HjRegion.HjRegion3D
object.RegionFactory.newRectangularRegion3D(int, int, int, int, int, int)
public static List<HjRegion.HjRegion1D> group(HjRegion.HjRegion1D hjRegion, int processorGrid)
processorGrid
chunks.
final HjRegion1D iterSpace = newRectangularRegion1D(0, N - 1);
final List hjRegionList = group(iterSpace, numWorkerThreads());
hjRegion
- The iteration space of the loopprocessorGrid
- The number of processors/threads to chunk the iteration space intoRegionFactory.groupRegion(edu.rice.hj.api.HjRegion.HjRegion1D, int)
public static HjRegion.HjRegion1D myGroup(int groupId, HjRegion.HjRegion1D hjRegion, int groupSize)
groupId
when the iteration space is divided into groupSize
groups.
final HjRegion1D iterSpace = newRectangularRegion1D(0, N - 1);
forallNb(0, tasks - 1, (t) -> {
final HjRegion1D myGroup = myGroup(t, iterSpace, tasks);
...
});
groupId
- The id of the group to retrieve. It should be less than groupSize
hjRegion
- The iteration spacegroupSize
- The number of groups the iteration space should have been dividedgroupId
when the iteration space is divided into groupSize
groups.RegionFactory.groupRegion(edu.rice.hj.api.HjRegion.HjRegion1D, int)
public static List<HjRegion.HjRegion2D> group(HjRegion.HjRegion2D hjRegion, int processorGrid0, int processorGrid1)
processorGrid0 x processorGrid1
chunks.
final HjRegion2D iterSpace = newRectangularRegion2D(1, M, 1, N);
final List hjRegionList = group(iterSpace, 4, 6);
hjRegion
- a HjRegion.HjRegion2D
object.processorGrid0
- a int.processorGrid1
- a int.List
object.RegionFactory.groupRegion(edu.rice.hj.api.HjRegion.HjRegion2D, int, int)
public static RectangularRegion2D myGroup(int groupId0, int groupId1, HjRegion.HjRegion2D hjRegion, int groupSize0, int groupSize1)
(groupId0, groupId1)
when the iteration space is divided
into groupSize0 x groupSize1
groups.
final HjRegion2D iterSpace = newRectangularRegion2D(1, M, 1, N);
forallNb(0, X - 1, 0, Y - 1, (i, j) -> {
final HjRegion2D myGroup = myGroup(i, j, iterSpace, M, N);
...
});
groupId0
- a int.groupId1
- a int.hjRegion
- a HjRegion.HjRegion2D
object.groupSize0
- a int.groupSize1
- a int.RectangularRegion2D
object.RegionFactory.groupRegion(edu.rice.hj.api.HjRegion.HjRegion1D, int)
public static void forseqNb(HjRegion.HjRegion1D hjRegion, HjProcedureInt1D body)
The semantics of
final HjRegion1D iterSpace = newRectangularRegion1D(startInc, endInc);
forseqNb(iterSpace, (k) -> S2(k))
are as follows:
for (int k = startInc; k <= endInc; k++) {
S2(k);
}
hjRegion
- The region to loop overbody
- The body of the looppublic static void forallNb(HjRegion.HjRegion1D hjRegion, HjProcedureInt1D body) throws SuspendableException
The semantics of
final HjRegion1D iterSpace = newRectangularRegion1D(startInc, endInc);
forallNb(iterSpace, (k) -> S2(k))
are as follows:
finish(() -> {
for (int k = startInc; k <= endInc; k++) {
final int kk = k;
async(() -> {
S2(kk);
});
}
});
hjRegion
- The region to loop overbody
- The body of the loopSuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasync(HjRegion.HjRegion1D hjRegion, HjProcedureInt1D body)
The semantics of
final HjRegion1D iterSpace = newRectangularRegion1D(startInc, endInc);
forasyncNb(iterSpace, (k) -> S2(k))
are as follows:
for (int k = startInc; k <= endInc; k++) {
final int kk = k;
async(() -> {
S2(kk);
});
}
hjRegion
- The region to loop overbody
- The body of the loopforasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forallNbChunked(HjRegion.HjRegion1D hjRegion, HjProcedureInt1D body) throws SuspendableException
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
hjRegion
- a HjRegion.HjRegion1D
object.body
- a HjProcedureInt1D
object.SuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncChunked(HjRegion.HjRegion1D hjRegion, HjProcedureInt1D body)
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
hjRegion
- a HjRegion.HjRegion1D
object.body
- a HjProcedureInt1D
object.forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forseqNb(int s0, int e0, int s1, int e1, HjProcedureInt2D body)
The semantics of
forallNb(s0, e0, s1, e1, (i, j) -> S2(i, j))
are as follows:
for (int i = s0; i <= e0; i++) {
for (int j = s1; j <= e1; j++) {
S2(i, j);
}
}
body
- The body of the loops0
- a int.e0
- a int.s1
- a int.e1
- a int.forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static HjRegion.HjRegion2D newRectangularRegion2D(int pMinInc0, int pMaxInc0, int pMinInc1, int pMaxInc1)
pMinInc0
- a int.pMaxInc0
- a int.pMinInc1
- a int.pMaxInc1
- a int.HjRegion.HjRegion2D
object.RegionFactory.newRectangularRegion2D(int, int, int, int)
public static void forseqNb(HjRegion.HjRegion2D hjRegion, HjProcedureInt2D body)
The semantics of
final HjRegion2D iterSpace = newRectangularRegion2D(s0, e0, s1, e1);
forseqNb(iterSpace, (i, j) -> S2(i, j))
are as follows:
for (int i = s0; i <= e0; i++) {
for (int j = s1; j <= e1; j++) {
S2(i, j);
}
}
hjRegion
- The region to loop overbody
- The body of the looppublic static void forallNb(int s0, int e0, int s1, int e1, HjProcedureInt2D body) throws SuspendableException
The semantics of
forallNb(s0, e0, s1, e1, (i, j) -> S2(i, j))
are as follows:
finish(() -> {
for (int i = s0; i <= e0; i++) {
final int ii = i;
for (int j = s1; j <= e1; j++) {
final int jj = j;
async(() -> {
S2(ii, jj);
});
}
}
});
body
- The body of the loops0
- a int.e0
- a int.s1
- a int.e1
- a int.SuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forallNb(HjRegion.HjRegion2D hjRegion, HjProcedureInt2D body) throws SuspendableException
The semantics of
final HjRegion2D iterSpace = newRectangularRegion2D(s0, e0, s1, e1);
forallNb(iterSpace, (i, j) -> S2(i, j))
are as follows:
finish(() -> {
for (int i = s0; i <= e0; i++) {
final int ii = i;
for (int j = s1; j <= e1; j++) {
final int jj = j;
async(() -> {
S2(ii, jj);
});
}
}
});
hjRegion
- The region to loop overbody
- The body of the loopSuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncNb(HjRegion.HjRegion2D hjRegion, HjProcedureInt2D body)
The semantics of
final HjRegion2D iterSpace = newRectangularRegion2D(s0, e0, s1, e1);
forasyncNb(iterSpace, (i, j) -> S2(i, j))
are as follows:
for (int i = s0; i <= e0; i++) {
final int ii = i;
for (int j = s1; j <= e1; j++) {
final int jj = j;
async(() -> {
S2(ii, jj);
});
}
}
hjRegion
- The region to loop overbody
- The body of the loopforasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncNb(int s0, int e0, int s1, int e1, HjProcedureInt2D body)
The semantics of
forasyncNb(s0, e0, s1, e1, (i, j) -> S2(i, j))
are as follows:
for (int i = s0; i <= e0; i++) {
final int ii = i;
for (int j = s1; j <= e1; j++) {
final int jj = j;
async(() -> {
S2(ii, jj);
});
}
}
body
- The body of the loops0
- a int.e0
- a int.s1
- a int.e1
- a int.forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
,
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
,
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
,
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forallNbChunked(int s0, int e0, int s1, int e1, HjProcedureInt2D body) throws SuspendableException
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
s0
- a int.e0
- a int.s1
- a int.e1
- a int.body
- a HjProcedureInt2D
object.SuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forallNbChunked(HjRegion.HjRegion2D hjRegion, HjProcedureInt2D body) throws SuspendableException
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
hjRegion
- a HjRegion.HjRegion2D
object.body
- a HjProcedureInt2D
object.SuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncNbChunked(HjRegion.HjRegion2D hjRegion, HjProcedureInt2D body)
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
hjRegion
- a HjRegion.HjRegion2D
object.body
- a HjProcedureInt2D
object.forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forseqNb(HjRegion.HjRegion3D hjRegion, HjProcedureInt3D body)
The semantics of
final HjRegion3D iterSpace = newRectangularRegion3D(s0, e0, s1, e1, s2, e2);
forseqNb(iterSpace, (i, j, k) -> S2(i, j, k))
are as follows:
for (int i = s0; i <= e0; i++) {
for (int j = s1; j <= e1; j++) {
for (int k = s2; k <= e2; k++) {
S2(i, j, k);
}
}
}
hjRegion
- The region to loop overbody
- The body of the looppublic static void forallNb(HjRegion.HjRegion3D hjRegion, HjProcedureInt3D body) throws SuspendableException
The semantics of
final HjRegion3D iterSpace = newRectangularRegion3D(s0, e0, s1, e1, s2, e2);
forallNb(iterSpace, (i, j, k) -> S2(i, j, k))
are as follows:
finish(() -> {
for (int i = s0; i <= e0; i++) {
final int ii = i;
for (int j = s1; j <= e1; j++) {
final int jj = j;
for (int k = s2; k <= e2; k++) {
final int kk = k;
async(() -> {
S2(ii, jj, kk);
});
}
}
}
});
hjRegion
- The region to loop overbody
- The body of the loopSuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncNb(HjRegion.HjRegion3D hjRegion, HjProcedureInt3D body)
The semantics of
final HjRegion3D iterSpace = newRectangularRegion3D(s0, e0, s1, e1, s2, e2);
forasyncNb(iterSpace, (i, j, k) -> S2(i, j, k))
are as follows:
for (int i = s0; i <= e0; i++) {
final int ii = i;
for (int j = s1; j <= e1; j++) {
final int jj = j;
for (int k = s2; k <= e2; k++) {
final int kk = k;
async(() -> {
S2(ii, jj, kk);
});
}
}
}
hjRegion
- The region to loop overbody
- The body of the loopforasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forallNbChunked(HjRegion.HjRegion3D hjRegion, HjProcedureInt3D body) throws SuspendableException
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
hjRegion
- a HjRegion.HjRegion3D
object.body
- a HjProcedureInt3D
object.SuspendableException
forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static void forasyncNbChunked(HjRegion.HjRegion3D hjRegion, HjProcedureInt3D body)
The HJ runtime ensures that it does not create more tasks than the number of available worker threads for the loop.
hjRegion
- a HjRegion.HjRegion3D
object.body
- a HjProcedureInt3D
object.forasyncNb(int, int, edu.rice.hj.api.HjProcedure)
public static int numPlaces()
public static HjPlace here()
public static HjPlace place(int id)
public static void asyncNbAt(HjPlace place, HjRunnable runnable)
place
- The place where the async task should run.runnable
- The body of the code to run, possibly asynchronously.asyncNb(edu.rice.hj.api.HjRunnable)
Copyright © 2015 Rice University - Department of Computer Science. All rights reserved.