|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.knowceans.util.ParallelFor
public abstract class ParallelFor
ParallelFor implements what in OpenMP is called a parallel for loop, i.e., a loop that executes in parallel on several threads with a barrier (join) at the end. Implementors simply subclass and implement the process() method and make sure the loop() method is not called while a loop of one instance is running. Execution can be stopped using stop(), which completes the iterations currently running. After the last usage of the class, it should be shut down properly using function shutdown() or the hard way using System.exit();
Constructor Summary | |
---|---|
ParallelFor()
instantiate with as many threads as there are processors |
|
ParallelFor(int nthreads)
instantiate a parallel for implementation |
Method Summary | |
---|---|
void |
loop(int N)
Start worker threads and loop through the iterations. |
void |
loopOnce(int N)
loops once, then shuts down |
static void |
main(java.lang.String[] args)
|
abstract void |
process(int iteration,
int thread)
payload for the for loop |
void |
shutdown()
shut down the thread pool after final usage |
void |
stop()
stop loop execution |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ParallelFor()
public ParallelFor(int nthreads)
Method Detail |
---|
public void loop(int N)
N
- public void loopOnce(int N)
N
- public abstract void process(int iteration, int thread)
iteration
- in the for loopthread
- on the machinepublic void stop()
public void shutdown()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |