Coordinating Data-Parallel SAC Programs with S-Net Sven-Bodo Scholz Clemens Grelck and Alex Shafarenko Compiler Technology and Computer Architecture Group University of Hertfordshire, UK HIPS-ToPMoDRS, 26.March 2007, Long Beach www.aether-ist.org Sven-Bodo Scholz Coordinating SAC with S-Net
SAC in a nutshell ◮ generic array programming ◮ purely functional ◮ no-frills ◮ aggressive program optimisation ◮ sequential performance competitive with fortran 77 ◮ generation of multi-threaded code without annotations For details see www.sac-home.org Sven-Bodo Scholz Coordinating SAC with S-Net
Exploitation of Data-Parallelism in SAC ◮ hinges on our data-parallel construct, the With-Loop ◮ all our array operations are defined by these ◮ granularity control by ◮ array size inference ◮ several fusion techniques ◮ architecture specific code generation ◮ POSIX-threads for SMPs ◮ taylor-made memory management ◮ almost linear speedups for examples such as NAS-benchmarks Sven-Bodo Scholz Coordinating SAC with S-Net
So what is the catch?? Our compiler maps all concur- rency into one Concurrency pat- tern: Sven-Bodo Scholz Coordinating SAC with S-Net
So what is the catch?? Our compiler maps all concur- rency into one Concurrency pat- tern: if our application cannot be mapped on this pattern, we cannot exploit its concurrency! Sven-Bodo Scholz Coordinating SAC with S-Net
An example: Search Algorithms Sven-Bodo Scholz Coordinating SAC with S-Net
Our Approach: S-Net Existing software S-Net : ◮ asynchronous component code framework ◮ functional stream code processing code ◮ pure coordination language code ◮ dynamic network creation code ◮ orthogonal to the box language code code Sven-Bodo Scholz Coordinating SAC with S-Net
S-Net at a Glance ◮ central construct: box wraps existing code box foo Sven-Bodo Scholz Coordinating SAC with S-Net
S-Net at a Glance ◮ central construct: box wraps existing code ◮ connected by ◮ single input stream ◮ single output stream box foo Sven-Bodo Scholz Coordinating SAC with S-Net
S-Net at a Glance ◮ central construct: box wraps existing code ◮ connected by ◮ single input stream ◮ single output stream ◮ streams transport records: sets of named fields ◮ opaque value fields ◮ integer-valued tag fields box foo {A,B,<T>} Sven-Bodo Scholz Coordinating SAC with S-Net
S-Net at a Glance ◮ central construct: box ◮ box behaviour declared by wraps existing code type signature ◮ connected by ◮ single input stream ◮ single output stream ◮ streams transport records: sets of named fields ◮ opaque value fields ◮ integer-valued tag fields box foo {A,B,<T>} {A,B,<T>} {X,<T>} Sven-Bodo Scholz Coordinating SAC with S-Net
S-Net at a Glance ◮ central construct: box ◮ box behaviour declared by wraps existing code type signature ◮ connected by ◮ behaviour defined in box ◮ single input stream language, not S-Net ◮ single output stream ◮ streams transport records: sets of named fields ◮ opaque value fields ◮ integer-valued tag fields box foo {A,B,<T>} {A,B,<T>} {X,<T>} Sven-Bodo Scholz Coordinating SAC with S-Net
S-Net at a Glance ◮ central construct: box ◮ box behaviour declared by wraps existing code type signature ◮ connected by ◮ behaviour defined in box ◮ single input stream language, not S-Net ◮ single output stream ◮ box maps single input ◮ streams transport records: record to stream of output sets of named fields records ◮ opaque value fields ◮ integer-valued tag fields box foo {X,<T>}; {A,B,<T>} {X,<T>}; {A,B,<T>} {X,<T>} Sven-Bodo Scholz Coordinating SAC with S-Net
Network Combinators: Serial box X := A..B A B Sven-Bodo Scholz Coordinating SAC with S-Net
Network Combinators: Choice box X := A..B A B box X := A||B A B Sven-Bodo Scholz Coordinating SAC with S-Net
Network Combinators: Serial Replication box X := A..B box X := A||B A A B B box X := A*{<stop>} A {<stop>} Sven-Bodo Scholz Coordinating SAC with S-Net
Network Combinators: Index Split box X := A..B box X := A||B box X := A*{<stop>} A A B A {<stop>} B box X := A!<T> A <T> A Sven-Bodo Scholz Coordinating SAC with S-Net
Primitive Boxes: Filter and Sync Filter {A,B,<T>} {A,<T>,<X>:=1}; {B,<T>,<X>:=2} housekeeping: ◮ eliminate record fields ◮ duplicate record fields ◮ add tags ◮ manipulate tag values ◮ ... Sven-Bodo Scholz Coordinating SAC with S-Net
Primitive Boxes: Filter and Sync Filter Sync {A,B,<T>} {A,B} {C,D} {A,<T>,<X>:=1}; {B,<T>,<X>:=2} {A,B,C,D} housekeeping: synchronisation: ◮ eliminate record fields ◮ keep record that matches pattern ◮ duplicate record fields ◮ all patterns matched: ◮ add tags release merged records ◮ manipulate tag values ◮ pattern already matched: ◮ ... pass through Sven-Bodo Scholz Coordinating SAC with S-Net
Problem: Incompatible Boxes box foo box bar ? {A,B} {C,X} {C,D} {X,Y} ◮ Box code typically designed in isolation. ◮ Interfaces only partially overlap. ◮ Network composition unfeasible in practice? Sven-Bodo Scholz Coordinating SAC with S-Net
Solution: Flow Inheritence flow inheritence bypass box foo { A,B,X } { C,D,X } {A,B} {C,D} ◮ Any “unwanted” field is bypassed to output channel ◮ and is attached to any record produced in response. Sven-Bodo Scholz Coordinating SAC with S-Net
Solution: Flow Inheritence flow inheritence bypass box foo { C,D,X } {A,B} { A,B,X } { C,D,X } {C,D} { C,D,X } ◮ Any “unwanted” field is bypassed to output channel ◮ and is attached to any record produced in response. Sven-Bodo Scholz Coordinating SAC with S-Net
Flow Inheritence: Enabling Network Combination {X} box foo box bar {A,B} {C,X} {C,D} {X,Y} {D} ◮ Flow inheritence is the key to network glue. Sven-Bodo Scholz Coordinating SAC with S-Net
How to apply this to our problem? box vert:= hor *{<done>} box hor:= solveOneLevel ! <k> box solveOneLevel {board, opts} −> {board, opts, <k>} | {board, <done>} <k> box solveOneLevel {board, opts} −> {board, opts, <k>} | {board, <done>} Sven-Bodo Scholz Coordinating SAC with S-Net
How to apply this to our problem? box vert:= hor *{<done>} box hor:= solveOneLevel ! <k> box solveOneLevel box hor:= solveOneLevel ! <k> {board, opts} −> {board, opts, <k>} box solveOneLevel {..., <k=0>} | {board, <done>} {board, opts} −> {board, opts, <k>} <k> | {board, <done>} box solveOneLevel <k> {board, opts} −> {board, opts, <k>} box solveOneLevel | {board, <done>} {board, opts} −> {board, opts, <k>} | {board, <done>} Sven-Bodo Scholz Coordinating SAC with S-Net
How to apply this to our problem? box solveOneLevel box vert:= hor *{<done>} {board, opts} −> {board, opts, <k>} | {board, <done>} <k=0> box hor:= solveOneLevel ! <k> box hor:= solveOneLevel ! <k> box solveOneLevel {..., <k=0>} {board, opts} −> {board, opts, <k>} box solveOneLevel | {board, <done>} {board, opts} −> {board, opts, <k>} | {board, <done>} <k> <k> box solveOneLevel {board, opts} −> {board, opts, <k>} box solveOneLevel | {board, <done>} {board, opts} −> {board, opts, <k>} | {board, <done>} Sven-Bodo Scholz Coordinating SAC with S-Net
How to apply this to our problem? {..., <k=0>} box solveOneLevel box vert:= hor *{<done>} {board, opts} −> {board, opts, <k>} | {board, <done>} <k=0> box hor:= solveOneLevel ! <k> {..., <k=1>} box hor:= solveOneLevel ! <k> box solveOneLevel {board, opts} −> {board, opts, <k>} box solveOneLevel | {board, <done>} {board, opts} −> {board, opts, <k>} | {board, <done>} <k> <k> box solveOneLevel {board, opts} −> {board, opts, <k>} box solveOneLevel | {board, <done>} {board, opts} −> {board, opts, <k>} | {board, <done>} Sven-Bodo Scholz Coordinating SAC with S-Net
Recommend
More recommend