Equation Solution High Performance by Design |
|||||||
|
|||||||
|
Java MTASK:
parallel programming language
MTASK, introduced in 1994, is a parallel programming language for memory-sharing environments. The original version is for Fortran programming. Java MTASK is converted from fortran version, and has some extensions. Java version of MTASK consists of the following components:
TASK MANIPULATION Java MTASK has four methods to manipulate tasks, which are:
1. dispatch( )
2. waitForAndTerminateAllTasks( ) 3. waitForAndTerminateTask( ) 4. dispose( ) In Java MTASK, computing streams those can be executed in parallel are programmed in a public method without a return, i.e., a public void method. For the purpose of easy illustration, we call the method, which initializes parallel execution, tasking method. Then, apply "dispatch( )" to start tasking method in parallel. One class can have more than one tasking method for parallelizing. The life cycle of a task starts at the beginning of the tasking method and ends with the "return" of the tasking method. Tasking method can call other methods or can refer to other class. The method "waitForAndTerminateAllTasks( )" is to join all tasks. The method "waitForAndTerminateTask( )" blocks the execution until a particular task is complete, and terminates the task. The method "dispose()" releases resource. PARALLEL LOCK Parallel lock is to access critical sections, and is an important mechanism for memory-sharing type of parallel processing. In Fortran, a critical section is bounded by "lockon" and "unlock" statements. Java object has an inner lock, and Java has an easier way of handling critical sections. In Java, a critical section can be written as: synchronized(parallelLock) { //statement of critical section //statement of critical section //statement of critical section } parallelLock.lockon( ); //statement of critical section //statement of critical section //statement of critical section parallelLock.unlock( );
1. lockon()
2. lockoff() 3. dispose() PARALLEL EVENT Parallel event is also an important component for memory-sharing type of parallel processing. It synchronizes cooperating tasks. MTASK has the following methods to handle parallel events:
1. initialize( )
2. post( ) 3. waitFor( ) 4. ifComplete( ) 5. complete( ) 6. dispose( ) The method "initialize" is to initialize a cycle of event for cooperating tasks to complete. The method "post" is to post a count to the event cycle. The method "waitFor" blocks the execution until the event is complete. The method "ifComplete" determines if an event cycle is complete. If an event cycle is not complete, the task is immediately blocked until the method "complete" is called by a cooperating task. If the method "ifComplete" finds the event cycle is complete, the task should call the method "complete" to unblock cooperating tasks. Parallel event is to synchronize parallelism. If there is no sequential segment after parallelism, the method "waitFor" can be applied to synchronize cooperating tasks. If there is a sequential segment after parallelism, the methods "ifComplete" and "complete" can be applied to synchronize cooperating tasks and execute sequential segment. SEQUENTIAL TOKEN Statments for tasks, by default, are executed by all cooperating tasks. A sequential segment that is allowed to be executed by one task is controlled by sequential token. Sequential token has the following methods:
1. initialize( )
2. access( ) 3. release( ) 4. dispose( ) The method "initialize" is to initialize a sequential token for accessing a sequential segment. The method "access" makes a request to access a sequential segment. If the request is granted, task may receive a flag to execute the sequential segment. If the request is denied, task will be blocked until the segment was executed, and returned with a flag to skip the segment. The method "dispose" releases resource. BARRIER Barrier forces cooperating tasks to pass a statement simultaneously. This is the simpest way to synchronize cooperating tasks. Parallel event with a count to complete is a general mechanism to synchronize tasks. Barrier has only one method "sync". |
||||||
|
|||||||