public final class PCDP
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
missingFinishMsg |
Modifier and Type | Method and Description |
---|---|
static void |
async(java.lang.Runnable runnable)
async creates an asynchronously executing task.
|
static void |
asyncAwait(java.lang.Runnable runnable,
java.util.concurrent.Future<? extends java.lang.Object>... futures)
Creates an asynchronous task whose execution is predicated on the
satisfaction of the futures passed to asyncAwait.
|
static void |
finish(java.lang.Runnable runnable)
finish waits for all tasks spawned in runnable to complete, as well as
any transitively spawned child, granchild, etc tasks.
|
static void |
forall(int startInc,
int endInc,
ProcedureInt1D body)
A similar loop-parallel construct to forasync, with the only difference
being that forall includes an implicit finish wrapping all asynchronous
tasks created.
|
static void |
forall2d(int startInc0,
int endInc0,
int startInc1,
int endInc1,
ProcedureInt2D body)
A two-dimensional variant on forall.
|
static void |
forall2dChunked(int start0,
int endInclusive0,
int start1,
int endInclusive1,
int chunkSize,
ProcedureInt2D body)
A two-dimensional variant of forallChunked.
|
static void |
forall2dChunked(int start0,
int endInclusive0,
int start1,
int endInclusive1,
ProcedureInt2D body)
A variant of two-dimensional forallChunked that internally selects a sane
chunk size.
|
static void |
forallChunked(int start,
int endInclusive,
int chunkSize,
ProcedureInt1D body)
A chunked variant of the forall APIs.
|
static void |
forallChunked(int start,
int endInclusive,
ProcedureInt1D body)
A variant of one-dimensional forallChunked that internally selects a sane
chunk size.
|
static void |
forasync(int startInc,
int endInc,
ProcedureInt1D body)
Construct to represent loop-level parallelism.
|
static void |
forasync2d(int startInc0,
int endInc0,
int startInc1,
int endInc1,
ProcedureInt2D body)
A two-dimensional variant on forasync, analogous to two nested parallel
loops.
|
static void |
forasync2dChunked(int start0,
int endInclusive0,
int start1,
int endInclusive1,
int chunkSize,
ProcedureInt2D body)
A two-dimensional variant of forasyncChunked.
|
static void |
forasync2dChunked(int start0,
int endInclusive0,
int start1,
int endInclusive1,
ProcedureInt2D body)
A variant of two-dimensional forasyncChunked that internally selects a
sane chunk size.
|
static void |
forasyncChunked(int start,
int endInclusive,
int chunkSize,
ProcedureInt1D body)
Semantically equivalent to forasync, but internally the runtime chunks
the defined parallel loop according to chunkSize.
|
static void |
forasyncChunked(int start,
int endInclusive,
ProcedureInt1D body)
A variant of one-dimensional forasyncChunked that internally selects a
sane chunk size.
|
static void |
forseq(int start,
int endInclusive,
ProcedureInt1D body)
An API in the same style as PCDP's parallel loop APIs, but which executes
the defined loop sequentially.
|
static void |
forseq2d(int start0,
int endInclusive0,
int start1,
int endInclusive1,
ProcedureInt2D body)
An API in the same style as PCDP's parallel loop APIs, but which executes
the defined loop sequentially.
|
static <R> java.util.concurrent.Future<R> |
future(java.util.concurrent.Callable<R> body)
Spawn an asynchronous task that returns a value of type
|
static <R> java.util.concurrent.Future<R> |
futureAwait(java.util.concurrent.Callable<R> runnable,
java.util.concurrent.Future<? extends java.lang.Object>... futures)
A hybridization of future() and asyncAwait().
|
static void |
isolated(java.lang.Object obj1,
java.lang.Object obj2,
java.lang.Runnable runnable)
Object-based isolation on two objects, obj1 and obj2.
|
static void |
isolated(java.lang.Object obj,
java.lang.Runnable runnable)
Object-based isolation on a single object.
|
static void |
isolated(java.lang.Runnable runnable)
Global isolated statement.
|
static int |
numThreads()
Retrieve the number of software threads the PCDP runtime was configured
with.
|
protected static final java.lang.String missingFinishMsg
public static void finish(java.lang.Runnable runnable)
runnable
- User-written body of the finish scope to execute.public static void async(java.lang.Runnable runnable)
runnable
- User-written body of the task.public static void forasync(int startInc, int endInc, ProcedureInt1D body)
The semantics of
forasync(startInc, endInc, (k) -> S2(k))
are as follows:
for (int k = startInc; k <= endInc; k++) {
final int kk = k;
async(() -> {
S2(kk);
});
}
startInc
- The start of the loop range this parallel loop executes
over (inclusive).endInc
- The end of the loop range this parllel loop executes over
(exclusive).body
- a ProcedureInt1D
object defining the body of the
parallel loop.public static void forasync2d(int startInc0, int endInc0, int startInc1, int endInc1, ProcedureInt2D body)
startInc0
- The starting value for the outermost sequential loop.endInc0
- The final value for the outermost sequential loop
(inclusive).startInc1
- The starting value for the innermost sequential loop.endInc1
- The final value for the innermost sequential loop
(inclusive).body
- a ProcedureInt2D
object defining the body of these
nested loops.public static void forall(int startInc, int endInc, ProcedureInt1D body)
startInc
- The start of the loop range this parallel loop executes
over (inclusive).endInc
- The end of the loop range this parllel loop executes over
(exclusive).body
- a ProcedureInt1D
object defining the body of the
parallel loop.public static void forall2d(int startInc0, int endInc0, int startInc1, int endInc1, ProcedureInt2D body)
startInc0
- The starting value for the outermost sequential loop.endInc0
- The final value for the outermost sequential loop
(inclusive).startInc1
- The starting value for the innermost sequential loop.endInc1
- The final value for the innermost sequential loop
(inclusive).body
- a ProcedureInt2D
object defining the body of these
nested loops.public static void forasyncChunked(int start, int endInclusive, int chunkSize, ProcedureInt1D body)
start
- The starting iteration for the parallel loopendInclusive
- The ending iteration for the parallel loop
(inclusive)chunkSize
- The number of iterations to chunk together for
processing by a single asynchronous taskbody
- The body of the loop to executepublic static void forasyncChunked(int start, int endInclusive, ProcedureInt1D body)
start
- The starting iteration for the parallel loopendInclusive
- The ending iteration for the parallel loop
(inclusive)body
- The body of the loop to executepublic static void forasync2dChunked(int start0, int endInclusive0, int start1, int endInclusive1, int chunkSize, ProcedureInt2D body)
start0
- The starting iteration for the outermost parallel loopendInclusive0
- The ending iteration for the outermost parallel loop
(inclusive)start1
- The starting iteration for the innermost parallel loopendInclusive1
- The ending iteration for the innermost parallel loop
(inclusive)chunkSize
- The number of iterations to chunk together for
processing by a single asynchronous taskbody
- The body of the loop to executepublic static void forasync2dChunked(int start0, int endInclusive0, int start1, int endInclusive1, ProcedureInt2D body)
start0
- The starting iteration for the outermost parallel loopendInclusive0
- The ending iteration for the outermost parallel loop
(inclusive)start1
- The starting iteration for the innermost parallel loopendInclusive1
- The ending iteration for the innermost parallel loop
(inclusive)body
- The body of the loop to executepublic static void forallChunked(int start, int endInclusive, int chunkSize, ProcedureInt1D body)
start
- The starting iteration for the parallel loopendInclusive
- The ending iteration for the parallel loop
(inclusive)chunkSize
- The number of iterations to chunk together for
processing by a single asynchronous taskbody
- The body of the loop to executepublic static void forallChunked(int start, int endInclusive, ProcedureInt1D body)
start
- The starting iteration for the parallel loopendInclusive
- The ending iteration for the parallel loop
(inclusive)body
- The body of the loop to executepublic static void forall2dChunked(int start0, int endInclusive0, int start1, int endInclusive1, int chunkSize, ProcedureInt2D body)
start0
- The starting iteration for the outermost parallel loopendInclusive0
- The ending iteration for the outermost parallel loop
(inclusive)start1
- The starting iteration for the innermost parallel loopendInclusive1
- The ending iteration for the innermost parallel loop
(inclusive)chunkSize
- The number of iterations to chunk together for
processing by a single asynchronous taskbody
- The body of the loop to executepublic static void forall2dChunked(int start0, int endInclusive0, int start1, int endInclusive1, ProcedureInt2D body)
start0
- The starting iteration for the outermost parallel loopendInclusive0
- The ending iteration for the outermost parallel loop
(inclusive)start1
- The starting iteration for the innermost parallel loopendInclusive1
- The ending iteration for the innermost parallel loop
(inclusive)body
- The body of the loop to executepublic static <R> java.util.concurrent.Future<R> future(java.util.concurrent.Callable<R> body)
R
- Return type of the launched future task.body
- user-defined body of the task.public static void asyncAwait(java.lang.Runnable runnable, java.util.concurrent.Future<? extends java.lang.Object>... futures)
runnable
- Body of the task.futures
- Future objects to block the spawned task on.public static <R> java.util.concurrent.Future<R> futureAwait(java.util.concurrent.Callable<R> runnable, java.util.concurrent.Future<? extends java.lang.Object>... futures)
R
- Return type of the launched future task.runnable
- Body of the task.futures
- Future objects to block the spawned task on.public static void forseq(int start, int endInclusive, ProcedureInt1D body)
start
- The starting value for the sequential loop.endInclusive
- The final value for the sequential loop (inclusive).body
- a ProcedureInt1D
object defining the body of these
nested loops.public static void forseq2d(int start0, int endInclusive0, int start1, int endInclusive1, ProcedureInt2D body)
start0
- The starting value for the outermost sequential loop.endInclusive0
- The final value for the outermost sequential loop
(inclusive).start1
- The starting value for the innermost sequential loop.endInclusive1
- The final value for the innermost sequential loop
(inclusive).body
- a ProcedureInt2D
object defining the body of these
nested loops.public static int numThreads()
public static void isolated(java.lang.Runnable runnable)
runnable
- The body to be executed in isolation.public static void isolated(java.lang.Object obj, java.lang.Runnable runnable)
obj
- The object to implement isolation on.runnable
- The body to be executed in isolation.public static void isolated(java.lang.Object obj1, java.lang.Object obj2, java.lang.Runnable runnable)
obj1
- The first object to implement isolation on.obj2
- The second object to implement isolation on.runnable
- The body to be executed in isolation.