9
Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

Embed Size (px)

Citation preview

Page 1: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

Informal Parallel Programming Course for High School Students

Fall 2007

By: Alex Valentin

Page 2: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

Who?

•Uzi Vishkin, UMD Professor

•Scott Watson, UMD Graduate Student

•10 Montgomery Blair Students

•Me

Page 3: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

Why?

• Think Differently

• Target younger audience

• Parallel is the Future

Page 4: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

What?

• Language: XMT-C– Spawn– Ps( )

• Hardware: 64-processor computer

Page 5: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

HW0: Exchange Problem

Swap elements from A[ ] with those of B[ ]

Input: A[ ], B[ ], n = length of arrays#include <xmtc.h> int main( ){int x;for(x=0; x<n; x++){int e= A[x];A[x] = B[x];B[x] = e;}//end for}//end main

#include <xmtc.h> int main(){spawn(0,n-1){Int x ; x= A[$];A[$] = B[$];B[$] = x[$];}//end for}//end main

Page 6: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

Optimal Parallel Exchangeint main(){int y[n];int x[n];spawn(0,2*n-1){if($<n) x[$] = A[$];else y[$%n] = B[$%n];}spawn(0, 2*n-1){if($<n) A[$] = y[$];else B[$%n] = x[$%n];}}

Page 7: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

HW3: Compaction

• Given a sparse array, copy all non-zero values into a new array

• Input: A[ ], B[ ], C[ ], n= length of arrays

• To be done in constant time, O(1)

Page 8: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

int main(void){int ptr=0;int l; for(l=0; l<n; l++){if(B[l] != 0){C[ptr] = A[l];ptr++;}}//end for}//end main

#include <xmtc.h>psBaseReg base;int main (void){base =0;

spawn(0, n-1){int step =1;if( B[$] != 0) {ps( step, base);C[step] = A[$];}}//end spawn}// end main

Compaction Code

Page 9: Informal Parallel Programming Course for High School Students Fall 2007 By: Alex Valentin

The Future

• Ear Decomposition Search ( EDS)– Sub-Graph of Input– Parallel equivalence of Depth-First-Search

• st-Numbering