U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Parallel & Concurrent Programming: Occam Vitaliy Lvin University of Massachusetts.

Slides:



Advertisements
Similar presentations
COMMUNICATING SEQUENTIAL PROCESSES C. A. R. Hoare The Queen’s University Belfast, North Ireland.
Advertisements

Programming in Occam-pi: A Tutorial By: Zain-ul-Abdin
Formal Semantics of Programming Languages 虞慧群 Topic 6: Advanced Issues.
(C) P. H. Welch1 Chapter 4 Fundamentals of occam.
Compiling Communicating Processes into Delay-Insensitive VLSI Circuits Alain J. Martin Department of Computer Science California Institute of Technology.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
U NIVERSITY OF M ASSACHUSETTS, A MHERST – Department of Computer Science The Implementation of the Cilk-5 Multithreaded Language (Frigo, Leiserson, and.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts Amherst Operating Systems CMPSCI 377 Lecture.
Informática II Prof. Dr. Gustavo Patiño MJ
Comp 205: Comparative Programming Languages Semantics of Imperative Programming Languages denotational semantics operational semantics logical semantics.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Introduction Data files –Can be created, updated,
Using a CSP based Programming Model for Reconfigurable Processor Arrays By: Zain-ul-Abdin
COMP 4—Power Tools for the Mind1 PowerTools What’s in the Box? Turing 1: An Introduction to Programming You will learn elementary computer programming.
Wednesday, 9/4/02, Slide #1 1 CS 106 Intro to CS 1 Wednesday, 9/4/02  Today: Introduction, course information, and basic ideas of computers and programming.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Advanced Compilers CMPSCI 710.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science pH: A Parallel Dialect of Haskell Jim Cipar & Jacob Sorber University of Massachusetts.
Programming Languages Structure
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.
Parallel and Distributed IR
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
1 10/25/06CS150 Introduction to Computer Science 1 Reading from and Writing to Files.
Pseudocode.
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
What is Concurrent Programming? Maram Bani Younes.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
COMPUTER SCIENCE I C++ INTRODUCTION
Introduction to Programming (in C++) Data and statements Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
An Introduction Chapter Chapter 1 Introduction2 Computer Systems  Programmable machines  Hardware + Software (program) HardwareProgram.
High-Level Programming Languages: C++
© P. H. Welch1 Occam 2 the Rest Chapter 10. © P. H. Welch2 {{{ occam 2 (the rest!) … ANSI/IEEE 754 floating-point … abbreviations … retyping … VAL OF.
TRANSPUTER ARCHITECTURE. What is Transputer ? The first single chip computer designed for message-passing parallel systems, in 1980s, by the company INMOS.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Gary MarsdenSlide 1University of Cape Town Principles of programming language design Gary Marsden Semester 2 – 2001.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
24-Aug-2015 Copyright P.H.Welch1 Managing Hard Real Times Peter Welch ( ) CPA 2015, University of Kent, 24 th. August, 2015 (28 Years Later)
Introduction to Computer Systems and the Java Programming Language.
Introduction To PROLOG World view of imperative languages. World view of relational languages. A PROLOG program. Running a PROLOG program. A PROLOG.
1 Parallel Programming Aaron Bloomfield CS 415 Fall 2005.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Algorithm Design.
ELEN 033 Lecture #1 Tokunbo Ogunfunmi Santa Clara University.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Fortress John Burgess and Richard Chang CS691W University of Massachusetts Amherst.
Chapter 4 MARIE: An Introduction to a Simple Computer.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
CS Computer Science I. BCPL was developed in 1967 as a language for writing operating systems and software compilers In 1970, the creators of the.
Chapter Six Introduction to Shell Script Programming.
Computer Programming CONTENTS Introduction to Operating Systems Introduction to programming languages Introduction to perl programming language Programming.
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
8 January 2016Birkbeck College, U. London1 Introduction to Programming Lecturer: Steve Maybank Department of Computer Science and Information Systems
CSC 143A 1 CSC 143 Introduction to C++ [Appendix A]
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
0 PROGRAMMING IN HASKELL Chapter 4 - Defining Functions.
© P. H. Welch1 Lego-Land ™ Chapter 5. © P. H. Welch2 … some simple networks.
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
COMPUTER PROGRAMMING Year 9 – lesson 1. Objective and Outcome Teaching Objective We are going to look at how to construct a computer program. We will.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
Conditional Expressions
REPETITION CONTROL STRUCTURE
The Metacircular Evaluator
Message Protocols Co631 (Concurrency)
CS150 Introduction to Computer Science 1
Life is Full of Alternatives
Presentation transcript:

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Parallel & Concurrent Programming: Occam Vitaliy Lvin University of Massachusetts Amherst

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 2 Today Before: languages that hid control of parallelism from the application programmer (ZPL, Flux) Extensions of existing languages to add control (Cilk, OpenMP) Libraries (MPI) Today: Occam – an explicitly parallel imperative language

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 3 Introduction to Occam The idea: from Communicating Sequential Processes, C.A.R. Hoare Parallel processes communicate through channels, not shared memory Channels can be read (?) and written to (!) Occam was designed in conjunction with the Transputer processor architecture

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 4 The First Example Hello, World! but with a parallel twist PROC hello.world (CHAN OF BYTE keyboard, screen, error) VAL []BYTE greeting1 IS “Hello ” : VAL []BYTE greeting2 IS “World ” : VAL []BYTE endl IS “*c*n” : SEQ PAR SEQ i = 0 FOR SIZE greeting1 screen ! greeting1[i] SEQ i = 0 FOR SIZE greeting2 screen ! greeting1[i] SEQ i = 0 FOR SIZE endl screen ! endl[i] :

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 5 Occam and processes In Occam, every instruction is a process: Primitive processes: assignment, channel input-output, STOP, SKIP Constructed processes: SEQ – sequential execution IF, CASE – branching WHILE – looping ALT, PRI ALT – alternation PAR – parallel execution repetition

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 6 Occam language constructs Part I SEQ straightforwardly combines a number of processes to be executed in order into one process IF & CASE have familiar semantics, except if no condition is matched, they behave like STOP and not SKIP WHILE behaves normally

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 7 Occam language constructs Part II PAR: combines a number of processes to be executed in parallel into one process Important restriction: no write-shared memory PAR -- this parallel is INVALID! SEQ mice := the variable mice is assigned.. c ! 42 c ? mice --..in more than one parallel component Use channels instead! (similar restrictions apply)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 8 Occam language constructs Part III ALT combines a number of processes, only one of which will be executed Which one gets executed is determined by a guard – usually a channel input A process whose input is ready – proceeds (SELECT) PRI ALT adds a notion of priority

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 9 ALT Example -- Regulator: -- regulate flow of work into a networked farm SEQ idle := processors WHILE running ALT from.workers ? result SEQ reg.to.gen ! result idle := idle + 1 (idle >= 1) & gen.to.reg ? packet SEQ to.workers ! packet idle := idle - 1

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 10 Channel input-output: To read from channel: channel ? variable(s) To write to it: channel ! expression(s) Channels have protocols associated with them which describe units of communication along them Replication: SEQ, IF, PAR & ALT can be replicated (for loop) Occam language constructs Part IV

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 11 FUNCTION and PROCEDURE are also processes VALOF creates a process that returns a value RESULT defines the return value INT FUNCTION sum (VAL []INT values) INT accumulator : VALOF SEQ accumulator := 0 SEQ i = 0 FOR SIZE values accumulator := accumulator + values[i] RESULT accumulator : Occam language constructs Part V

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 12 Occam Data Types Primitive types: BOOL, BYTE, INT(16/32/64), REAL32/64 Arrays Records (structs) Types can be: Aliased Converted (changes underlying representation) Reshaped (leaves underlying representation intact)

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 13 Exercise Write a simple program that echoes user input to stdout and stderr in parallel

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 14 Solution PROC double.echo (CHAN OF BYTE keyboard, screen, error) BYTE ch: SEQ ch := ' ' WHILE TRUE SEQ keyboard ? ch PAR SEQ screen ! ch screen ! FLUSH SEQ error ! ch error ! FLUSH :

U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science 15 Conclusion Very clean language tailored for a particular hardware architecture Very low-level at the same time Allows for significant amount of mathematical analysis of programs Current work – Occam-pi (CSP + Pi calculus)