Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
EEAA:: SSpprriinngg1111:: EExxppaannddiinngg PPDDCC CCoovveerraaggee iinn aaMMaatthhFFooccuusseedd 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: 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 (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 SSTEM, 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 threeweek PDC course
modules (20% of our 15week semester)targeting three required 2ndyear courses.
AY 201112: Four threeweek advanced PDCcourse modules in programming anddistributed computing targeting electivestypically offered every three semesters.
AY 201213: Moving PDC topics further downinto CS1 and CS2, fleshing out PDC coveragein our intermediate objectorienteddevelopment 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 201314: 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
• 9hour 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 2by2 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 OObbjjeeccttOOrriieenntteedd 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 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)
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. 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 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 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 (QRcode above).
EEdduuPPaarr ''1144
FFuuttuurree PPllaannssComputer Systems/CS3
• Loyola course number: COMP 264• offered every spring• envisioning PDC module with suitable architecture,
programming, and crosscutting 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 fiveyear 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: 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 PPrrooggrraammmmiinngg LLaanngguuaaggeess
• 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
// 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? : )