Name (print *CLEARLY*): _________________________________________________


Student ID (print *CLEARLY*; 1 digit per underline): _____ _____ _____ _____ _____ _____

CSE 231s Quiz 26: Pipeline, Data Driven, and Phaser

Future<String> aFuture = future(()->{
    
return "A";
});
Future<String> bFuture = future(await(aFuture), ()->{
    String a = aFuture.get();
    
return a + "B";
});
Future<String> cFuture = future(await(aFuture), ()->{
    String a = aFuture.get();
    
return a + "C";
});
Future<String> dFuture = future(await(bFuture), ()->{
    String b = bFuture.get();
    
return b + "D";
});
Future<String> eFuture = future(await(bFuture, cFuture), ()->{
    String b = bFuture.get();
    String c = cFuture.get();
    
return b + c + "E";
});
Future<String> fFuture = future(await(cFuture), ()->{
    String c = cFuture.get();
    
return c + "F";
});
Future<String> gFuture = future(await(eFuture, fFuture), ()->{
    String e = eFuture.get();
    String f = fFuture.get();
    
return e + f + "G";
});
//H
async(await(dFuture, gFuture), ()->{
    String d = dFuture.get();
    String g = gFuture.get();
    System.out.println(d + g + 
"H");
});

Draw the dataflow graph:

* What does the code above print?

 

Phaser phaser = new Phaser();
phaser.register();
finish(() -> {
       async(() -> {
              s1();
             
phaser.arrive();
              s2();
       });
       async(() -> {
              s3();
             
phaser.awaitAdvance(0);
              s4();
       });
       s5();
});

s6();

s1 can run in parallel with: _________________

s2 can run in parallel with: _________________

s3 can run in parallel with: _________________

s4 can run in parallel with: _________________

s5 can run in parallel with: _________________

s6 can run in parallel with: _________________

Draw the computation graph:


Imagine you have a large file you would like to read in (WORK=1), compress(WORK=4), encrypt(WORK=2), and write out(WORK=3). This file can be split into a 10 parts and fed into a a four stage pipeline.

* Encircle the statements that comprise the critical path below:

read(0) W=1      
read(1) W=1 compress(0) W=4    
read(2) W=1 compress(1) W=4 encrypt(0) W=2  
read(3) W=1 compress(2) W=4 encrypt(1) W=2 write(0) W=3
read(4) W=1 compress(3) W=4 encrypt(2) W=2 write(1) W=3
read(5) W=1 compress(4) W=4 encrypt(3) W=2 write(2) W=3
read(6) W=1 compress(5) W=4 encrypt(4) W=2 write(3) W=3
read(7) W=1 compress(6) W=4 encrypt(5) W=2 write(4) W=3
read(8) W=1 compress(7) W=4 encrypt(6) W=2 write(5) W=3
read(9) W=1 compress(8) W=4 encrypt(7) W=2 write(6) W=3
  compress(9) W=4 encrypt(8) W=2 write(7) W=3
    encrypt(9) W=2 write(8) W=3
      write(9) W=3

* WORK = _____________________________________

* CPL = _____________________________________