ProcessJ: A Possible Future of Process-Oriented Design

1 ProcessJ: A Possible Future of Process-Oriented DesignJ...
Author: Arthur Wade
0 downloads 2 Views

1 ProcessJ: A Possible Future of Process-Oriented DesignJan Bækgaard Pedersen (UNLV) Marc L. Smith (Vassar) CPA-2013 25-28 August 2013

2 What do we have to do …. Question: What do we have to do tospread the word about/use of process oriented design? make the experience more easily accessible? convince the distributed programming community that it actually is a good idea? (This might include hostage taking) Show that it can actually be used for HPC?

3 What do we have to do …. Answer:Easy to learn language with the right semantics Syntax of a familiar language (business as usual) Safer semantics (but you can’t do those bad things!) Incorporation into online teaching tools Accessible from anywhere Easy to use in classrooms and teaching settings Educational material Finally someone will write “the book” (Peter?!) Supporting course material (videos, …)

4 Legends A B Technical A B A B Educational IDE/GUI Process repo. Cloudstorage Prog. language Compiler Runtime B uses A Technical A B A makes B A B Executable CSP scripts FDR verifier B is based on A Web tool (teaching) New parts Existing tools Learning material Course templates Educational Slides Notes Books Lecture material Videos

5 What should these be? Legends A B Technical A B A B EducationalIDE/GUI Process repo. Legends A B Cloud storage Prog. language Compiler Runtime B uses A Technical A B A makes B A B What should these be? Executable CSP scripts FDR verifier B is based on A Web tool (teaching) New parts Existing tools Learning material Course templates Educational Slides Notes Books Lecture material Videos

6 New Language (again) Why not just provide a library for C/Java?C: Too general – let you do bad things on purpose Pointers Shared memory Java/JVM: Threading model of runtime too coarse Speed? Those pesky objects with wait and notify…. If the programmer does not promise to behave 100% things will definitely go wrong. Programmer must stick to the “CSP Model”

7 New Language (again) Perhaps a new syntax with a pre-processor and a source to source translator A possibility – with some checking New language might more easily achieve and incorporate what we want Integration of CSP generation Might require a separate parser anyway

8 New Language (again) New language with the whole package (and more)“known” syntax (like Java-ish) Has communication primitives with CSP semantics Synchronous channel communication Barriers Alternations Parallel composition Mobility (pi-calculus) Has C/Java semantics for all other sequential language constructs Has no shared memory abilities/pointers Fast runtime system with multi-core scheduler

9 Legends A B Technical A B A B Educational IDE/GUI Process repo. Cloudstorage ProcessJ language ProcessJ compiler Runtime (ccsp) B uses A Technical A B A makes B A B Executable CSP scripts FDR verifier B is based on A Web tool (teaching) New parts Existing tools Learning material Course templates Educational Slides Notes Books Lecture material Videos

10 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

11 Education is EverythingProcess-Oriented Design We must teach it… …if we want students to learn it The longer we wait The harder it is to teach The harder it is to learn The less natural it feels The lower our chance of success

12 Language is EverythingForget about ProcessJ for a moment… and programming languages Programming languages Natural languages The language we speak shapes our thoughts Teach foreign languages too late children unlikely to become multilingual

13 Programming Language is EverythingThe language we learn to program in shapes how we solve problems Teach concurrent languages too late students unlikely to become parallel programmers We may say we care more about concurrency and process-oriented design more than any language… …but without an accessible process-oriented language, concurrency remains inaccessible

14 The Wrong Debate(s)! The CS Education community has been debating the wrong things: FP vs OOP ? Objects first vs Objects early vs Objects later vs Objects late ? What about: Sequential vs Concurrent ? The debate that hasn’t happened (yet!) Institutional bias toward sequential! We teach it like we learned it

15 Race[condition]ism! Conventional wisdom: Conventional Wisdom is wrong!Concurrency is hard! Hard to write (from an ingrained sequential mindset) Hard to test (too many possible interleavings!) Hard to debug (Heisenbugs) In short: Hard to reason about! Conventional Wisdom is wrong! CW applies to particular models of concurrency Thread s and Locks with shared memory Asynchronous message passing

16 Special Sequential InterestsCompositional blind spot! Sequential composition (in Java or your favorite OOL) Data composes (i.e., data structures) Code composes (i.e., code blocks) Data and Methods compose (i.e., classes) Classes compose (i.e., packages/libraries) Packages compose (i.e., frameworks) Concurrent Composition? Threads don’t compose group of threads Asynchronous message passing larger collection of objects and message buffers

17 Process-Oriented Abstraction is EverythingCompositional / Concurrency Abstraction Processes compose explicitly: Sequentially Parallel Choice (alternation) The composition of two or more processes is a process! (which can in turn be further composed) Reason about processes at an appropriate level of abstraction (internal hiding)

18 Process-Oriented Design Makes All the DifferenceLowest level processes are sequential CSP, after all, stands for Communicating Sequential Processes Parallel composition is just another choice for composition, alongside sequential (;) composition! With the right language and syntax, Process-Oriented design could be taught: First? Early? Later? Late? The earlier the better—let’s not debate this!

19 ProcessJ is Everything

20 Timing is Everything ACM/IEEE-CS Joint Task Force for Computing Curricula. Computer Science Curricula 2013, Ironman Draft includes for the first time Parallel Programming in the Core [undergraduate] Curriculum new Knowledge Area (KA): Parallel and Distributed Computing Concurrency is no longer an elective topic!

21 Context is Everything (from the Ironman draft)“Parallel computing: Among the many changes to the Body of Knowledge compared to previous reports is a new Knowledge Area in Parallel and Distributed Computing. An alternative structure for the Body of Knowledge would place relevant topics in other Knowledge Areas: parallel algorithms with algorithms, programming constructs in software-development focused areas, multi-core design with computer architecture, and so forth. We chose instead to provide guidance on the essential parallelism topics in one place. Some, but not all, curricula will likely have courses dedicated to parallelism, at least in the near term.”

22 From a Research PerspectiveNSF Call for Proposals: “New programming languages and language mechanisms that support new computational models, raise the level of abstraction, and lower the barrier of entry for parallel and concurrent programming. Parallel and concurrent languages that have programmability, verifiability, and scalable performance as design goals. Of particular interest are languages that abstract away from the traditional imperative programming model found in most sequential programming languages.”

23 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

24 Support is Everything We must help make it easier for faculty to consider adopting Process-Oriented Design in their courses The Web Tool will be the portal to supporting materials, including Learning material: notes, book(s), lectures Course templates Slides and videos

25 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

26 ProcessJ Language ProcessJ has Java-like syntax Without objectsWith records and arrays CSP primitives: Synchronous channels Alternation Barriers Protocols …. All the good stuff we know from occam

27 ProcessJ Language Java like statements for while, do, for etc.with Java/C semantics Channel communication, alternation etc. with CSP semantics Process Mobility pi-calculus Polymorphic resumption interfaces

28 ProcessJ Example proc void Producer (chan.write out) { int x = 42; while (true) { while (x < 1000) { out.write (x); x++; } while (x > 0) { out.write (x); x--; } }

29 ProcessJ Example proc void Producer (chan.write out) { int x = 42; while (true) { while (x < 1000) { out.write (x); x++; } while (x > 0) { out.write (x); x--; } } Writing end of a channel carrying integers; named out.

30 ProcessJ Example proc void Producer (chan.write out) { int x = 42; while (true) { while (x < 1000) { out.write (x); x++; } while (x > 0) { out.write (x); x--; } } Write the value of x to the channel out.

31 ProcessJ Example proc void Producer (chan.write out) { int x = 42; while (true) { while (x < 1000) { out.write (x); x++; } while (x > 0) { out.write (x); x--; } }

32 ProcessJ Example proc void Monitor (chan.read in) {int last = in.read (); while (true) { int x; x = in.read (); if (x == last) { ... system failure detected } last = x;

33 ProcessJ Example proc void Monitor (chan.read in) {int last = in.read (); while (true) { int x; x = in.read (); if (x == last) { ... system failure detected } last = x; Reading end of a channel carrying integers; named in.

34 ProcessJ Example proc void Monitor (chan.read in) {int last = in.read (); while (true) { int x; x = in.read (); if (x == last) { ... system failure detected } last = x; Reading from the channel named in

35 ProcessJ Example proc void Monitor (chan.read in) {int last = in.read (); while (true) { int x; x = in.read (); if (x == last) { ... system failure detected } last = x;

36 ProcessJ Example proc void main() { chan c; par {Producer (c.write); Monitor (c.read); }

37 ProcessJ Example proc void main() { chan c; par {Producer (c.write); Monitor (c.read); } Declare a channel carrying integers

38 ProcessJ Example proc void main() { chan c; par {Producer (c.write); Monitor (c.read); } In parallel run Producer and Monitor

39 ProcessJ Example proc void main() { chan c; par {Producer (c.write); Monitor (c.read); }

40 ProcessJ Example proc void Producer (chan.write out) { int x = 42; while (true) { while (x < 1000) { out.write (x); x++; } while (x > 0) { out.write (x); x--; } } proc void Monitor (chan.read in) { int last = in.read (); while (true) { int x; x = in.read (); if (x == last) { ... system failure detected } last = x; proc void main() { chan c; par { Producer (c.write); Monitor (c.read); }

41 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

42 ProcessJ Compiler New compiler written in C/C++ using the CCSP runtime. Other back ends: JavaScript for online teaching tool MPI Generates CSP-M for FDR 3 ( ;-) ) checking

43 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

44 GUI for ProcessJ Process oriented programming is well suited for graphical programming Processes are nodes Channels are arcs Processes can consist of other processes which can consist of other processes etc. Processes are building blocks for other processes We have a “Lego” catalogue of well known processes Code reuse is as easy as drag and drop (and connect external channels)

45 GUI for ProcessJ GUI should integrate intoProcess repository Online Cloud Storage GUI should produce CSP based on process layout And perhaps also documentation Visual occam is a graphical programming interface (M.Sc. Thesis project) – proof of concept. Works for occam Written in Java

46 GUI – Visual occam

47 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

48 ProcessJ Process RepositoryLike the Apple App Store, but with source Free ;-) For developers/programmers ProcessJ code can be shared Annotated with CSP assertions certificate Deadlock free, livelock free, .. Programmer generated assertions Example code for use can be associated

49 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

50 Cloud Storage Online storage of ProcessJ code / CSP Accessible throughWeb interface (ProcessJ website) GUI Online Teaching Tool Integrating well known storage sites like GitHub Google Drive Dropbox

51 Technical Educational IDE/GUI Process repo. Cloud storage ProcessJlanguage ProcessJ compiler Runtime (ccsp) Technical Executable CSP scripts FDR verifier Web tool (teaching) Learning material Course templates Educational Slides Notes Books Lecture material Videos

52 ProcessJ Online Teaching ToolWeb tool (massive open online course) Written in HTML 5 Contains ProcessJ editor Cloud Storage access Process Repository access Compilation done remotely – execution done locally Remote compiler returns JavaScript and a JavaScript CSP runtime. Integrates teaching materials Notes, videos, etc (like codingbat etc.)

53 ProcessJ Online Teaching Tool

54 Aliasing Issues Data structures for creating graphs etc are importantIf you can’t do what you normally do in the language no one wants it! Parallel usage checking might be hard (impossible) to do at compile time Maybe offer runtime checking (expensive, but if you want all the bells and whistles, it will cost you!) ????

55 Us and Them (The Environment)Paper arose from an NSF proposal (that did not get funded) seeking “New programming languages and language mechanisms that support new computational models, raise the level of abstraction, and lower the barrier of entry for parallel and concurrent programming. Parallel and concurrent languages that have programmability, verifiability, and scalable performance as design goals. Of particular interest are languages that abstract away from the traditional imperative programming model found in most sequential programming languages.” Some of the comments might give an insight into what ‘they’ think Shows us what the computing community thinks about process oriented design Might help us devise different strategies

56 Us and Them (The Environment)“At times, the proposal is talking about CSP as a panacea. Unfortunately, this (in my opinion) reveals ignorance of the richness of both the problem space (types of applications) and the solution space (known models for parallel or concurrent computation), and thus undermines the credibility of success. For example, try writing a well-performing parallel matrix multiplication in CSP.”

57 Us and Them (The Environment)Matrix multiplication: for (i=0 ; i

58 Us and Them (The Environment)ProcessJ parallel matrix multiplication: par for (i=0 ; i Or a systolic array of n*n processes

59 Us and Them (The Environment)“The inclusion of a graphical interface / IDE is a nice idea, but orthogonal as a research problem. “Graphical IDEs have been around forever, but have never made it beyond the fringe. They tend to survive only if supported by a monopolistic proprietary owner.” This shows a lack of understanding of the power of programming-by-picture and the importance of composability. Learning curve cannot be too high (for the GUI) Used in VLSI for decades!

60 Us and Them (The Environment)“Can’t you just use Google’s Go?”

61 Us and Them (The Environment)“Can’t you just use Google’s Go?”

62 Talk amongst yourselves; I’ll give you a topic:“The future of Process Oriented Programming” Discuss!!!