Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 " Teaching Parallel Design Patterns to Undergraduates in Computer Science” Panel member SIGCSE 2014 - The 45 th ACM Technical Symposium on Computer Science.

Similar presentations


Presentation on theme: "1 " Teaching Parallel Design Patterns to Undergraduates in Computer Science” Panel member SIGCSE 2014 - The 45 th ACM Technical Symposium on Computer Science."— Presentation transcript:

1 1 " Teaching Parallel Design Patterns to Undergraduates in Computer Science” Panel member SIGCSE 2014 - The 45 th ACM Technical Symposium on Computer Science Education Saturday March 8, 2014, 9:00 am - 10:15 am Dr. Barry Wilkinson University of North Carolina, Charlotte SIGCSE2014.ppt Modification date: March 5, 2013

2 This is a collaborative project with: 2 Dr. Clayton Ferner University of North Carolina Wilmington

3 Problem Addressed To make parallel programming more useable and scalable. Using parallel patterns becoming established as a way forward. Our approach - develop higher level pattern programming tools so that students do not write low level MPI or OpenMP code (initially). 3 Students get their code working very quickly, low learning curve, good design practices, Avoid low level issues such as message deadlock

4 “Seeds” Parallel Grid Application Framework developed at UNC-Charlotte 4 Some Key Features Higher level pattern programming Several common higher level patterns implemented -- workpool, synchronous all-to-all, synchronous stencil, pipeline etc. Self-deploys on personal computers, clusters, and geographically distributed computers Very simple programming interface (Java) Students can write and test their code on their own computers, with minimal effort to deploy software.

5 Seeds programming Example: Workpool Generally three phases: 1.Master diffuses data to slaves 2.Slaves performs computations 3.Master gathers results for slaves Programmer only has to implement three basic methods, Diffuse, Compute, and Gather, without implementing low level message passing routines 5 Diffuse Compute Gather Master Slaves Master Message passing Slaves Master

6 package edu.uncc.grid.example.workpool; import java.util.Random; import java.util.logging.Level; import edu.uncc.grid.pgaf.datamodules.Data; import edu.uncc.grid.pgaf.datamodules.DataMap; import edu.uncc.grid.pgaf.interfaces.basic.Workpool; import edu.uncc.grid.pgaf.p2p.Node; public class MonteCarloPiModule extends Workpool { private static final long serialVersionUID = 1L; private static final int DoubleDataSize = 1000; double total; int random_samples; Random R; public MonteCarloPiModule() { R = new Random(); } public void initializeModule(String[] args) { total = 0; Node.getLog().setLevel(Level.WARNING); // reduce verbosity for logging random_samples = 3000; // set number of random samples } public int getDataCount() { return random_samples; } 6 public Data DiffuseData (int segment) { DataMap d =new DataMap (); d.put("seed", R.nextLong()); return d; // returns a random seed for each job unit } public Data Compute (Data data) { // input gets the data produced by DiffuseData() DataMap input = (DataMap )data; DataMap output = new DataMap (); Long seed = (Long) input.get("seed"); // get random seed Random r = new Random(); r.setSeed(seed); Long inside = 0L; for (int i = 0; i < DoubleDataSize ; i++) { double x = r.nextDouble(); double y = r.nextDouble(); double dist = x * x + y * y; if (dist <= 1.0) { ++inside; } output.put("inside", inside);// store partial answer to return to GatherData() return output; // output will emit the partial answers done by this method } public void GatherData (int segment, Data dat) { DataMap out = (DataMap ) dat; Long inside = (Long) out.get("inside"); total += inside; // aggregate answer from all the worker nodes. } public double getPi() { // returns value of pi based on the job done by all the workers double pi = (total / (random_samples * DoubleDataSize)) * 4; return pi; } Example Complete code (Monte Carlo pi) Note: No explicit message passing Computation Gather Diffuse Final results By framework

7 Seeds Implementations PP-2.7 Three Java versions available: Full JXTA P2P version requiring an Internet connection JXTA P2P version but not needing an external network, suitable for a single computer Multicore (thread-based) version for operation on a single computer Multicore version much faster execution on single computer. Only difference is minor change in bootstrap class that deploys and executes code.

8 Bootstrap class that deploys and executes code (Multicore version) public class RunMonteCarloPiModule { public static void main(String[] args) { try { MonteCarloPiModule pi=new MonteCarloPiModule(); Thread id = Seeds.startPatternMulticore( new Operand( (String[])null, new Anchor( args[0], Types.DataFlowRole.SINK_SOURCE), pi ),4); id.join(); System.out.println( "The result is: " + pi.getPi() ) ; } catch (SecurityException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }

9 Matrix multiplication Courtesy of Ben Barbour, Research Assistant/graduate student, Dept. of Computer Science, UNC- Wilmington 9

10 Experiences in the classroom 61 students Pattern programming first introduced into joint UNC-C/UNC-W parallel programming course in Fall 2012. NCREN course across two campuses Fall 2013 – Five universities across North Carolina:

11 Acknowledgements Extending work to teaching environment supported by the National Science Foundation under grant "Collaborative Research: Teaching Multicore and Many-Core Programming at a Higher Level of Abstraction" #1141005/1141006 (2012-2015). Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the National Science Foundation. Work initiated by Jeremy Villalobos in his PhD thesis “Running Parallel Applications on a Heterogeneous Environment with Accessible Development Practices and Automatic Scalability,” UNC-Charlotte, 2011. Jeremy developed “Seeds” pattern programming software.


Download ppt "1 " Teaching Parallel Design Patterns to Undergraduates in Computer Science” Panel member SIGCSE 2014 - The 45 th ACM Technical Symposium on Computer Science."

Similar presentations


Ads by Google