Difference between revisions of "V5"

From CSE231 Wiki
Jump to navigation Jump to search
Line 2: Line 2:
  
 
=async, finish=
 
=async, finish=
async and finish make up the fundamental building blocks of task-level parallelism in [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/edu/wustl/cse231s/v5/V5.html V5].
+
async and finish are the fundamental building blocks of task-level parallelism in [https://www.cse.wustl.edu/~cosgroved/courses/cse231/current/apidocs/edu/wustl/cse231s/v5/V5.html V5].
  
 
These concepts are first covered in [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/be41f5f2b11a4445aa4be174e94f1717/1 RiceX Topic 1.1].
 
These concepts are first covered in [https://edge.edx.org/courses/RiceX/COMP322/1T2014R/courseware/a900dd0655384de3b5ef01e508ea09d7/be41f5f2b11a4445aa4be174e94f1717/1 RiceX Topic 1.1].

Revision as of 18:09, 17 July 2018

We have created our own implementation of some of the concepts introduced in the X10 parallel programming language (paper) and its Habanero continuation.

async, finish

async and finish are the fundamental building blocks of task-level parallelism in V5.

These concepts are first covered in RiceX Topic 1.1.

async(body) creates a new child task that can run before, after, or in parallel with all remaining statements of the parent task.

finish(body) executes body and waits for all descenent tasks to complete.

In the example below, a() and b() may execute in parallel, however execution will not continue to c() until a() and b() have completed. This is a result of the semantics of finish which waits for the execution of the body it receives to complete and all of its descendant tasks terminate. a() is assured to have completed as it is a descendant task. b() is assured to have completed since it is in the normal continuation of the body passed to finish.

finish(()-> {
    async(()->{
        a();
    });
    b();
}
c();

future

A future is a task that returns a value.

Futures are covered in RiceX Topic 2.1.


loop parallelism

Attention niels epting.svg Warning:CSE 231s is all exclusive max, all the time. forall, forasync, and forseq are all exclusive max.

forasync

forasync(0, size, (i)->{
    ...
} );

can be thought of as:

for( int _i=0; _i<size; _i++ ) {
    final int i = _i;
    async( ()->{
        ...
    });
}

forall

forall(0, size, (i)->{
    ...
} );

is just forasync wrapped in a finish:

finish(()-> {
    forasync(0, size, (i)->{
        ...
    } );
});

forseq

forseq(0, size, (i)->{
    ...
} );

is equivalent to a standard for loop:

for( int i=0; i<size; i++ ) {
    ...
}

chunked

the chunked() option to the forasync, forall, forasync2d, and forall2d splits up the work in a way that the runtime system sees fit.