EA: Spring11: Expanding PDC Coverage in a MathFocused...

1
E E A A : : S S p p r r i i n n g g 1 1 1 1 : : E E x x p p a a n n d d i i n n g g P P D D C C C C o o v v e e r r a a g g e e i i n n a a M M a a t t h h F F o o c c u u s s e e d d C C S S 1 1 a a n n d d a a ( ( F F u u n n c c t t i i o o n n a a l l ) ) P P L L C C o o u u r r s s e e Joe Kaylor • Konstantin Läufer • Chandra Sekharan • George K. Thiruvathukal Department of Computer Science • Loyola University Chicago • USA www.cs.luc.edu • [email protected] • edupar.cs.luc.edu C C a a r r n n e e g g i i e e C C l l a a s s s s i i f f i i c c a a t t i i o o n n • Level: 4year or above • Control: Private notforprofit • Undergraduate Instructional Program: Bal/HGC • Graduate: CompDoc*/MedVet • Enrollment Profile: MU • Undergraduate Profile: FT4/MS/HTI • Size and Setting: L4/R • Basic: RU/H: Research Universities (high research activity) • Community Engagement: Curricular, Outreach, Partnerships *CS/SE/IT: up to masters' level I I n n s s t t i i t t u u t t i i o o n n a a l l P P r r o o f f i i l l e e • Urban, priv, Jesuit, lib. arts, ~16k students • College of Arts and Sciences, ~8k students • Dept. of Computer Science, ~300 students • 10 FT faculty: 9 CS, 1 bioinf (1/2 FTE), 1 algebraist (1/4 FTE) • ~140 undergrad majors in CS, SE, IT, Networks & Security, bioinformatics • ~50 UG minors in CS, computer forensics • ~110 master's students in CS, SE, IT • External funding: NSF SSTEM, NSF BPC lead institution, NSF research grants, industry • Very early adopters: '97 concurrency course, OOPSLA '98 edu symp paper, HPJPC book P P o o s s i i t t i i o o n n S S t t a a t t e e m m e e n n t t s s [for discussion] • To teach PDC topics effectively, they should not be taught in isolation. Instead, they should be taught in the context of relevant software engineering best practices. • Mobile applications backed by RESTful cloud services are rapidly emerging as the mainstream paradigm of computing [Christensen, OOPSLA '09]. PDC curricula should embrace it. P P r r i i o o r r O O u u t t c c o o m m e e s s Spring 2011: Three threeweek PDC course modules (20% of our 15week semester) targeting three required 2ndyear courses. AY 201112: Four threeweek advanced PDC course modules in programming and distributed computing targeting electives typically offered every three semesters. AY 201213: Moving PDC topics further down into CS1 and CS2, fleshing out PDC coverage in our intermediate objectoriented development course (CS 313), and stepping up evaluation. W W h h e e r r e e o o u u r r G G r r a a d d u u a a t t e e s s G G o o • Industry ~ 75% • midwest, coasts, international • consulting, finance, software, telecom, ... • Academia and Government ~ 15% • Argonne, county admin, local universities • Graduate School ~ 5% • local, national • Professional Schools ~ 5% • business, law, medical A A b b s s t t r r a a c c t t / / C C u u r r r r e e n n t t F F o o c c u u s s AY 201314: 1) Enhanced PDC coverage in a mathematically focused version of CS1 (CS 215) and 2) expanded PDC coverage in our programming languages course (CS 372). C C S S 1 1 • Loyola course number: COMP 170 • includes some material on numerical methods at the K and C levels • about 9 class hours were dedicated to sequential and parallel versions of these algorithms and the possible resulting speedup using data parallelism in C# example: threads for speeding up trapezoidal rule integration C C S S 2 2 • Loyola course number: COMP 271 • emphasis on PDC topics in CS2 starting in fall 2011 • 9hour PDC module on task parallelism, speedup, and load balancing in algorithms involving arbitrary precision arithmetics • presentation at the C and A levels in the form of various examples • example: compute Fibonacci numbers based on repeated squaring of 2 by2 matrices of BigIntegers in Java • experiment with the speedup resulting from executing lines (3) and (4) in separate threads • explore load balancing between these unequal tasks I I n n t t e e r r m m e e d d i i a a t t e e O O b b j j e e c c t t O O r r i i e e n n t t e e d d D D e e v v e e l l o o p p m m e e n n t t • Loyola course number: COMP 313 • since fall 2011: C#, emphasis on PDC topics • since fall 2012: Java with Android as highly effective context for studying concurrency and distributed computing topics (C and A levels) • subject of forthcoming NSF/TCPP CDER PDC book chapter • double 18hour PDC module (intervowen) • concurrency and coordination (C) • design forces: safety, liveness, performance (C) • asynchronicity: external events and internal timers (A) • background threads (A) • progress reporting and cancelation (A) • offloading computation from mobile device to cloud (C/A) • throughputlatency tradeoff (C) E E v v a a l l : : L L e e a a r r n n i i n n g g A A s s s s e e s s s s m m e e n n t t Sample concurrency questions: Suppose we have two philosophers. The first one, Kant, repeatedly behaves like so: think for 10 minutes wait for any available fork and grab it when available think for 2 minutes wait for any available fork and grab it when available eat for 5 minutes release both forks The second one, Heidegger, repeatedly behaves like so: think for 11 minutes wait for any available fork and grab it when available think for 2 minutes wait for any available fork and grab it when available eat for 5 minutes release both forks Suppose Kant and Heidegger sit at the same table with two forks available and start their respective behaviors at the same time. Give an event trace such as: At minute 4, Kant takes fork 1. ... Which type of undesirable situation does this scenario illustrate? a. lack of thread safety b. runtime type error c. memory leak d. deadlock What are possible ways of avoiding this kind of undesirable situation? • use an explicit locking mechanism to enforce mutually exclusive access to each fork • provide at least one more fork • treat both forks as a single resource bundle that must be acquired together at the same time • provide a fork and a knife instead of two forks and rewrite the behaviors such that each philosopher must acquire the fork first E E v v a a l l : : C C o o u u r r s s e e E E f f f f e e c c t t i i v v e e n n e e s s s s Sample questions (5pt Likert scale): Rate BEFORE/AFTER taking this course • your eventbased programming expertise • your threadbased concurrency expertise • your cloud computing expertise • your feeling of preparedness for the job market • the effectiveness of Android for learning event based programming Results available at edupar.cs.luc.edu (QR code above). E E d d u u P P a a r r ' ' 1 1 4 4 F F u u t t u u r r e e P P l l a a n n s s Computer Systems/CS3 • Loyola course number: COMP 264 • offered every spring • envisioning PDC module with suitable architecture, programming, and crosscutting topics Algorithms/CS7 • Loyola course number: COMP 363 • offered every fall • developing PDC module: models of computation and complexity, basic algorithmic paradigms, and specific problems and their algorithmic solutions Evaluation • Once our course modules have stabilized, we will need to measure their effectiveness longitudinally over a three to fiveyear period. • Refine our current evaluation approach by working with Loyola’s Center for Science & Math Education, as well as the TCPP and fellow early adopters. Dissemination: workshops for subsequent adopters in the Midwest C C S S 1 1 w w i i t t h h m m a a t t h h e e m m a a t t i i c c a a l l f f o o c c u u s s • Loyola course number: COMP/MATH 215 • Planned for spring 2015 • includes some material on numerical methods at the K and C levels • about 9 class hours to be dedicated to sequential and parallel versions of these algorithms and the possible resulting speedup using data parallelism in C# example: threads for speeding up trapezoidal rule integration Example: local/remote prime checker • Android app: bruteforce prime checker • remote task returns quickly, local one is still churning Example: countdown timer external events: button presses internal timers: oneshot and recurring modelviewadapter (MVA) architecture design patterns: Observer, State, Façade P P r r o o g g r r a a m m m m i i n n g g L L a a n n g g u u a a g g e e s s • Loyola course number: COMP 372 • gradually increasing PDC coverage starting in spring 2010 • 10.5hour PDC module on mutable versus immutable state (C) asynchronous/reactive programming, futures and promises (A) threads (C) actors (C/A) other paradigms (K/C), e.g., softwaretransactional memory, taskparallel library

Transcript of EA: Spring11: Expanding PDC Coverage in a MathFocused...

Page 1: EA: Spring11: Expanding PDC Coverage in a MathFocused ...tcpp.cs.gsu.edu/curriculum/sites/default/files/EA- Spring-11- Expanding PDC Coverage in...EA: Spring11: Expanding PDC Coverage

EEAA:: SSpprriinngg­­1111:: EExxppaannddiinngg PPDDCC CCoovveerraaggee iinn aaMMaatthh­­FFooccuusseedd CCSS11 aanndd aa ((FFuunnccttiioonnaall)) PPLL CCoouurrsseeJoe Kaylor • Konstantin Läufer • Chandra Sekharan • George K. ThiruvathukalDepartment of Computer Science • Loyola University Chicago • USAwww.cs.luc.edu • [email protected] • edupar.cs.luc.edu

CCaarrnneeggiiee CCllaassssiiffiiccaattiioonn• Level: 4­year or above

• Control: Private not­for­profit

• Undergraduate Instructional Program: Bal/HGC

• Graduate: CompDoc*/MedVet

• Enrollment Profile: MU

• Undergraduate Profile: FT4/MS/HTI

• Size and Setting: L4/R

• Basic: RU/H: Research Universities (highresearch activity)

• Community Engagement: Curricular, Outreach,Partnerships

*CS/SE/IT: up to masters' level

IInnssttiittuuttiioonnaall PPrrooffiillee• Urban, priv, Jesuit, lib. arts, ~16k students

• College of Arts and Sciences, ~8k students

• Dept. of Computer Science, ~300 students

• 10 FT faculty: 9 CS, 1 bioinf (1/2 FTE), 1algebraist (1/4 FTE)

• ~140 undergrad majors in CS, SE, IT,Networks & Security, bioinformatics

• ~50 UG minors in CS, computer forensics

• ~110 master's students in CS, SE, IT

• External funding: NSF S­STEM, NSF BPC leadinstitution, NSF research grants, industry

• Very early adopters: '97 concurrency course,OOPSLA '98 edu symp paper, HPJPC book

PPoossiittiioonn SSttaatteemmeennttss

[for discussion]

• To teach PDC topics effectively, they shouldnot be taught in isolation. Instead, theyshould be taught in the context of relevantsoftware engineering best practices.

• Mobile applications backed by RESTful cloudservices are rapidly emerging as themainstream paradigm of computing[Christensen, OOPSLA '09]. PDC curriculashould embrace it.

PPrriioorr OOuuttccoommeessSpring 2011: Three three­week PDC course

modules (20% of our 15­week semester)targeting three required 2nd­year courses.

AY 2011­12: Four three­week advanced PDCcourse modules in programming anddistributed computing targeting electivestypically offered every three semesters.

AY 2012­13: Moving PDC topics further downinto CS1 and CS2, fleshing out PDC coveragein our intermediate object­orienteddevelopment course (CS 313), and steppingup evaluation.

WWhheerree oouurr GGrraadduuaatteess GGoo• Industry ~ 75%

• midwest, coasts, international• consulting, finance, software, telecom, ...

• Academia and Government ~ 15%• Argonne, county admin, local universities

• Graduate School ~ 5%

• local, national• Professional Schools ~ 5%

• business, law, medical

AAbbssttrraacctt//CCuurrrreenntt FFooccuussAY 2013­14: 1) Enhanced PDC coverage in a

mathematically focused version of CS1 (CS215) and 2) expanded PDC coverage in ourprogramming languages course (CS 372).

CCSS11• Loyola course number: COMP 170

• includes some material on numerical methods at the K and C levels

• about 9 class hours were dedicated to sequential and parallel versionsof these algorithms and the possible resulting speedup using dataparallelism in C#

• example: threads for speeding up trapezoidal rule integration

for (i = 0; i < numThreads; i++) {// create and start new child threadsits[i] =new IntegTrap1Region(start, end, granularity, fn) ;childThreads[i] = new Thread(new ThreadStart(its[i] . run) ) ;childThreads[i] . Start() ;// set the range for the next threadstart = end;end = a + (i + 2. 0d) / numThreads * range;

}for (i = 0; i < numThreads; i++) {

// wait for child threads to finishchildThreads[i] . Join() ;totalArea += its[i] . getArea() ;

}

CCSS22• Loyola course number: COMP 271

• emphasis on PDC topics in CS2 starting in fall 2011

• 9­hour PDC module on task parallelism, speedup, and load balancing inalgorithms involving arbitrary precision arithmetics

• presentation at the C and A levels in the form of various examples

• example: compute Fibonacci numbers based on repeated squaring of 2­by­2 matrices of BigIntegers in Java

• experiment with the speedup resulting from executing lines (3) and (4) in separatethreads

• explore load balancing between these unequal tasks

public BigInteger[] matMultFib(final BigInteger[] fibK) {final BigInteger[] matFib2K =new BigInteger[2] ;matF[0] = fibK[0] . multiply(fibK[0] ) . add(fibK[1] . multiply(fibK[1] ) ) ;matF[1] = fibK[1] . multiply(fibK[0] . shiftLeft(1) . add(fibK[1] ) ) ;return matFib2K;

}

IInntteerrmmeeddiiaattee OObbjjeecctt­­OOrriieenntteedd DDeevveellooppmmeenntt• Loyola course number: COMP 313

• since fall 2011: C#, emphasis on PDC topics

• since fall 2012: Java with Android as highly effective context forstudying concurrency and distributed computing topics (C and A levels)

• subject of forthcoming NSF/TCPP CDER PDC book chapter

// local task: i is the number to checkfinal long half = i / 2;final double dHalf = half;for (long k = 2; k <= half; k += 1) {

if (isCancelled() ) break;publishProgress(

(int) ((k / dHalf) * 100) ) ;if (i % k == 0) return false;

}return true;

// remote task: invoke same code on serverclient. get(url, new AsyncHttpResponseHandler() {

@Override public void onSuccess(. . . ) {input. setBackgroundColor(

statusCode == 200 ? GREEN : MAGENTA) ;}@Override public void onFinish() {

progressBar. setProgress(100) ;. . .

• double 18­hour PDC module (intervowen)

• concurrency and coordination (C)• design forces: safety, liveness, performance (C)• asynchronicity: external events and internal

timers (A)• background threads (A)• progress reporting and cancelation (A)• offloading computation from mobile device to

cloud (C/A)• throughput­latency tradeoff (C)

EEvvaall:: LLeeaarrnniinngg AAsssseessssmmeennttSample concurrency questions:Suppose we have two philosophers. The first one, Kant, repeatedlybehaves like so:

think for 10 minuteswait for any available fork and grab it when availablethink for 2 minuteswait for any available fork and grab it when availableeat for 5 minutesrelease both forks

The second one, Heidegger, repeatedly behaves like so:think for 11 minuteswait for any available fork and grab it when availablethink for 2 minuteswait for any available fork and grab it when availableeat for 5 minutesrelease both forks

Suppose Kant and Heidegger sit at the same table with two forksavailable and start their respective behaviors at the same time. Givean event trace such as:

At minute 4, Kant takes fork 1....

Which type of undesirable situation does this scenario illustrate?a. lack of thread safety b. run­time type error c. memory leak d. deadlock

What are possible ways of avoiding this kind of undesirable situation?• use an explicit locking mechanism to enforce mutually exclusive access toeach fork

• provide at least one more fork• treat both forks as a single resource bundle that must be acquired togetherat the same time

• provide a fork and a knife instead of two forks and rewrite the behaviorssuch that each philosopher must acquire the fork first

EEvvaall:: CCoouurrssee EEffffeeccttiivveenneessssSample questions (5pt Likert scale): Rate

BEFORE/AFTER taking this course• your event­based programming expertise• your thread­based concurrency expertise• your cloud computing expertise• your feeling of preparedness for the job market• the effectiveness of Android for learning event­

based programming

Results available at edupar.cs.luc.edu (QRcode above).

EEdduuPPaarr ''1144

FFuuttuurree PPllaannssComputer Systems/CS3

• Loyola course number: COMP 264• offered every spring• envisioning PDC module with suitable architecture,

programming, and cross­cutting topicsAlgorithms/CS7

• Loyola course number: COMP 363• offered every fall• developing PDC module: models of computation and

complexity, basic algorithmic paradigms, andspecific problems and their algorithmic solutions

Evaluation

• Once our course modules have stabilized, we willneed to measure their effectiveness longitudinallyover a three­ to five­year period.

• Refine our current evaluation approach by workingwith Loyola’s Center for Science & Math Education,as well as the TCPP and fellow early adopters.

Dissemination: workshops for subsequentadopters in the Midwest

def integrateSeq(a: Double, b: Double, n: Int, f: Fx) : Double = {val interval = (b - a) / nval fxValues = (1 until n) . view map { i => f(a + i * interval) }interval * (f(a) / 2 + f(b) / 2 + fxValues. sum)

}

CCSS11 wwiitthh mmaatthheemmaattiiccaall ffooccuuss• Loyola course number: COMP/MATH 215

• Planned for spring 2015

• includes some material on numerical methods at the K and C levels

• about 9 class hours to be dedicated to sequential and parallel versionsof these algorithms and the possible resulting speedup using dataparallelism in C#

• example: threads for speeding up trapezoidal rule integration

def integratePar(a: Double, b: Double, n: Int, f: Fx) : Double = {val interval = (b - a) / nval fxValues = (1 until n) . par. view map { i => f(a + i * interval) }interval * (f(a) / 2 + f(b) / 2 + fxValues. sum)

}

Example: local/remote prime checker

• Android app: brute­force prime checker• remote task returns quickly, local one is still

churning

Example: countdown timer

• external events: button presses• internal timers: one­shot and recurring• model­view­adapter (MVA) architecture• design patterns: Observer, State, Façade PPrrooggrraammmmiinngg LLaanngguuaaggeess

• Loyola course number: COMP 372

• gradually increasing PDC coverage starting in spring 2010

• 10.5­hour PDC module on

­ mutable versus immutable state (C)­ asynchronous/reactive programming, futures and promises (A)­ threads (C)­ actors (C/A)­ other paradigms (K/C), e.g., software­transactional memory, task­parallel library

// monoid = semigroup with identity, enables parallel reduce// (functor provides map, can usually be parallelized as well)zero[Int] assert_=== 03 | +| zero[Int] assert_=== 33 | +| 4 assert_=== 7

zero[List[Int] ] assert_=== List. emptyList(1, 2) | +| zero[List[Int] ] assert_=== List(1, 2)List(1, 2) | +| List(3) assert_=== List(1, 2, 3)

zero[String] assert_=== "" // etc.

def twice[T: Monoid] (x: T) = x | +| xtwice(3) assert_=== 6twice(List(1, 2) ) assert_=== List(1, 2, 1, 2)twice("hello" ) assert_=== "hellohello"

// futures for composing asynchronous computationsval candidates = Seq(1003, 10003, 100003, 1000003)val futures: Seq[Future[(Int, Boolean) ] ] =

candidates map { n => Future { (n, isPrime(n) ) } }val f1: Future[Seq[(Int, Boolean) ] ] =

Future. traverse(futures) (identity) // can now operate asynchronouslyval f2: Future[Seq[Int] ] = // on values wrapped in future

f1 map { xs => xs filter { case (_, b) => b } map { n => n. _1 } }val f3: Future[Int] = f2 map { ns => ns sum }f3 foreach println // <--- what does this print? : )