Abstract Memory The TupleSpace Linda, JavaSpaces, Tspaces and PastSet
Tuple Space Main idea: Byte ordered memory is a product of hardware development, not programmers needs Remodel memory to support the application view on memory, i.e. more complex datastructures
Tuples A tuple is a vector representation of a data-structure Tuples are typically identified by a flag in the beginning of the tuple ( Student, Kurt,Bachelor,8.12); is an instance of a template ( Student,Name, Level, GPA)
TupleSpace ("Person", "John Doe", 21,6.5) ("Pi", 3.14) ("Color", Blue)
TupleSpaces Implementations Multitude of different implementations Linda JavaSpaces Tspaces PastSet Many more!
Linda First implementation of the TupleSpace Closely integrated with the target language C-Linda C++ Linda Fortran-Linda Ada-Linda
Linda Operations Out place a tuple in the TupleSpace In take a tuple from the TupleSpace Rd - a tuple-copy from the TupleSpace Eval place a new task in to TupleSpace
Linda Examples out( Person, Doe, John, 23, 82, BLUE); out( Person, Last_name, First_name, Age,\ Weight, Eye_color); in( Person,? Last_name,? First_name,? Age,\? Weight,? Eye_color); in( Person,? Last_name,? First_name, 32, \? Weight, GRAY);. in( Person,? Last_name,? First_name, 32, \? Weight, color);.
JavaSpaces SUN s approach to TupleSpace Works on generic objects rather than tuples Read and take are nonblocking! Tuples can grow old and die in JavaSpaces
JavaSpaces - Operations Write - writes an object into a JavaSpace Read - gets a copy of an object in a JavaSpace Take - retrieves an object from a JavaSpace Notify - attempts to notify an object that an object of a specified type has been written to the JavaSpace
Tspaces Tuple oriented version in Java Stronger semantics than JavaSpaces Tuples are somewhat hard to access Supports Preserialized objects Encurrages the use of many spaces
Tspaces Operations Write Read Take WaitToTake
PastSet PastSet should allow programmers to use shared memory techniques PastSet should provide memory consistency as a synchronization mechanism PastSet should provide debugging features similar to message-traces PastSet performance should be comparable to message-passing
PastSet Memory Model Tuples rather than bytes ( pi,(double)) Tuples with same template are stacked in an element Each element maintains sequential consistency Last-First < Last First 6 5 4 3 2 1 0
PastSet Memory Model 42,2,72 33,0.0 2,4.6 1,3.14 "Tabel",(int),(float) John Doe Betty Boo Popeye "Name",(string[255]) 1 0 0 0 1 "Taken",(bool)
PastSet Operations Enter get a handle for a tuple-template Mv place a tuple in the TupleSpace Ob read a tuple from the TupleSpace Unindexed; read the next previously unread tuple Indexed; read a specified tuple in the sequence Mob first Mv then Ob Last 6 5 4 3 First 2 1 0
PastSet Operations Spawn start a new task Axe allow PastSet to delete tuples that are smaller than or equal to the specified number DelElement remove an element from PastSet All of which are a necessity more than an integrated part of the idea
URMS User Redefinable Memory Semantics
A Simple URMS Example Global reduction, similar to MPI_Allreduce Worker 1... URMS cell (Global Sum[32]) Worker 32 Read Global Sum Read Global Sum Write Partiel Sum Write Partiel Sum
URMS Barrier implementation The URMS function simply collects n writes before making them visible b=enterdimension( My Barrier, NULL, BARRIER, n); Mob(b, NULL, b, NULL);
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS Barrier Mob Mob Mob Mob Barrier Element
URMS in Java PastSet public interface URMSFunction extends Serializable { public Serializable filterin(element e, Serializable data); public int filterout(element e, Serializable data); } Reduce sum = new Reduce(n) { public Serializable operator(serializable a, Serializable b) { return new Integer(((Integer) a).intvalue() + ((Integer) b).intvalue()); } };
URMS for Parallel Processing A set of URMS functions can be taken directly from the group operations in MPI Sum, Product, Min, etc. Sorting data BLAS operations Fine grained parallelism queues can be optimized for data locality
URMS for Grid Remote Databases Many databases are huge and the users often wish to extract data that are hard to describe use db languages Either programmers need to transfer all data and filter locally Or the db site allows users to start threads at the db-server to filter locally Or URMS can make a best-of-both
Mapping a db-query to DSM SQL query PastSet db-library db-query 'cut-to-mem' Application Postgres
Data Distribution in PastSet Handled by a central element-server Central Server Round Robin First Touch
Latency Test observe(); //Observe the initial token get_start_time(); //Get timestamp for(i=0; i<1000; i++){ move(); //Send token to right neighbor observe(); //Get token from left neighbor } get_stop_time();
Latency Test
Ring test PastSet only
Ring test
Bandwidth Test get_start_time(); for(i=0; i<1000; i++) move(); //Write data-block to PastSet get_stop_time(); get_start_time(); for(i=0; i<1000; i++) observe(); //Read a data-block from PastSet get_stop_time();
Bandwidth Test
Lattice Gas Automaton
LGA Performance
Nbody n 2 complexity
Nbody Performance
Raytracer
Raytracer Performance
N-Queens Problem
N-Queens Problem Classic combinatoric problem similar to TSP The demonstrated solution is sub-optimal it can be improved by detection potential foldings and mirroring
N-Queen Sequential void make_boards(int i) { for(int y = 0 ; y < n ; y++){ all[i] = y ; if( legal(i) ) { if( i+1 == n ) count++; else make_boards(i+1); } } }
N-Queens Job type import java.io.*; class Job implements Serializable { int row; int [] pos; }
N-Queens Tspaces - Master ts=new TupleSpace("QUEENS","roadrunner00"); ts.write(new Tuple("Result", new Integer(0), new Integer(0))); Job job = new Job(); job.pos=new int[n]; job.row=0; for(int i=0;i<n;i++) job.pos[i]=0; template.add(new Field("Job")); template.add(new FieldPS(job));
N-Queens TSpaces Worker(){ try{ TupleSpace ts = new TupleSpace( QUEENS", roadrunner00 ); Tuple jobtemplate =new Tuple("Job",MANGLER); Tuple d=ts.waittotake(jobtemplate); job=((job)d.getfield(1).getvalue()); while(job!=null){ Queens(i); d=ts.take(jobtemplate); job=((job)d.getfield(1).getvalue()); } ts.write("result",new Integer(count)); } catch(tuplespaceexception tse) { } }
N-Queens TSpaces void make_boards(job job){ job.i++; for(int y = 0 ; y < n ; y++){ all[job.i] = y ; if( legal(job) ) { if(i<parallel_cut_off){ write_job(job); } else { if( i+1 == n ) count++; else make_boards(job.clone()); } } } }