SMPL A Simple Parallel Language Ajay S S Reddy Challa Andrei - - PowerPoint PPT Presentation

smpl
SMART_READER_LITE
LIVE PREVIEW

SMPL A Simple Parallel Language Ajay S S Reddy Challa Andrei - - PowerPoint PPT Presentation

SMPL A Simple Parallel Language Ajay S S Reddy Challa Andrei Papancea Devashi Tandon Computing over the Years 1 1 - http://smoothspan.wordpress.com/2007/09/06/a-picture-of-the-multicore-crisis/ Computing over the Years Gordon E. Moore


slide-1
SLIDE 1

SMPL

A Simple Parallel Language

Ajay S S Reddy Challa Andrei Papancea Devashi Tandon

slide-2
SLIDE 2

Computing over the Years1

1 - http://smoothspan.wordpress.com/2007/09/06/a-picture-of-the-multicore-crisis/
slide-3
SLIDE 3

Computing over the Years

slide-4
SLIDE 4

Gordon E. Moore

  • 1965:

published a paper concerning the future of processor chips

  • Moore's Law:

"the number of transistors on integrated circuits doubles approximately every two years"

slide-5
SLIDE 5

The Free Lunch

  • Faster processors means

faster programs

  • No additional effort
slide-6
SLIDE 6

SMPL: It’s simple!

  • C syntax
  • introduces 4 new keywords that allow

parallelism

○ spawn ○ barrier ○ lock ○ pfor

  • the 4 parallel constructs use Posix threads
slide-7
SLIDE 7

SPAWN

  • The spawn statement creates a thread for

the given statement. Its syntax looks as follows: spawn function_call;

slide-8
SLIDE 8

BARRIER

  • The barrier statement prevents execution
  • f code following it until all the threads

spawned prior to it finish executing. Its syntax looks as follows: barrier;

slide-9
SLIDE 9

LOCK

  • The lock statement prevents other threads

from accessing or modifying the contents of the statement that it precedes until the latter’ s computation finishes. Its syntax looks as follows: lock statement

slide-10
SLIDE 10

PFOR

  • The pfor statement defines a for loop that

splits up the work in its body into multiple

  • threads. Its syntax has the following format:

pfor(k; counter; init; limit) statement

slide-11
SLIDE 11
  • This is a quick example on how to use

spawn and barrier:

A more exciting “Hello world!”

1 2 3 4 5 6 7 8 9 10 11 say(string str){ printf(“%s\n”,str); } int main(){ spawn say(“Hello”); spawn say(“world”); spawn say(“user!”); barrier; printf(“Done!\n”); }

slide-12
SLIDE 12
  • This is a quick example on how to use pfor:

Well, hey there multicore!

1 2 3 4 5 6 7 8 9 10 11 12 13 int sum = 0; int main(){ int i; int n = 1000000; pfor(8; i; 1; n){ sum = sum+i; } printf("The sum of the first 1M integers is %d.\n",sum); }

slide-13
SLIDE 13
  • This is a quick example on how to use lock:

Lock the vault!

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 float balance = 2000.00; withdraw(float val){ lock { if(balance-val >= 0) balance = balance-val; } } int main(){ int i; int n = 1000000; for(i=1; i<100; i++){ float amount = i*10; spawn withdraw(amount); } printf("The remaining balance is %f.\n",balance); }
slide-14
SLIDE 14

Implementation

  • semantic checker

○ automatic type casting ○ code validation ○ optimization (reference count)

  • code generation

○ C code generation ○ optimization (remove dead code)

  • testing

○ check syntax ○ check semantics (manually) ○ check program execution

slide-15
SLIDE 15

Lessons learned

  • Ajay

○ meeting regularly is crucial ○ keeping SMPL simple helped in the development process

  • Andrei

○ start early ○ OCaml is extremely annoying at first, yet extremely powerful ○ do not attempt to implement 10,000 language features

  • Devashi

○ coming up with a new language was fruitful and tricky ○ writing a compiler in a completely new language was challenging ○ I learned how to effectively work in a team

slide-16
SLIDE 16

DEMO