Problem-solving on large-scale clusters: theory and applications Lecture 1: Introduction and Theoretical Background.

Slides:



Advertisements
Similar presentations
Chapter 7. Binary Search Trees
Advertisements

Recursion 2014 Spring CS32 Discussion Jungseock Joo.
Haskell Lets review some of the Haskell concepts you have been learning on your own. The answers are included, but try it yourself first.
MATH 224 – Discrete Mathematics
Lecture 7: Basis Functions & Fourier Series
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Lecture 3: Parallel Algorithm Design
Problem-solving on large-scale clusters: theory and applications Lecture 3: Bringing it all together.
Recursion Great fleas have little fleas upon their backs to bite 'em, And little fleas have lesser fleas, and so ad infinitum. And the great fleas themselves,
Recursion CS /02/05 L7: Files Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved Iteration.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture11: Variants of Turing Machines Prof. Amos Israeli.
MapReduce: Simplified Data Processing on Large Clusters Cloud Computing Seminar SEECS, NUST By Dr. Zahid Anwar.
0 PROGRAMMING IN HASKELL Chapter 7 - Higher-Order Functions.
1 Chapter 18 Recursion Dale/Weems/Headington. 2 Chapter 18 Topics l Meaning of Recursion l Base Case and General Case in Recursive Function Definitions.
Discrete Mathematics Recursion and Sequences
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
CS 206 Introduction to Computer Science II 10 / 08 / 2008 Instructor: Michael Eckmann.
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
CHAPTER 10 Recursion. 2 Recursive Thinking Recursion is a programming technique in which a method can call itself to solve a problem A recursive definition.
Lecture 2 – MapReduce: Theory and Implementation CSE 490h – Introduction to Distributed Computing, Spring 2007 Except as otherwise noted, the content of.
Finite State Machines Data Structures and Algorithms for Information Processing 1.
analysis, plug ‘n’ chug, & induction
DATA STRUCTURE Subject Code -14B11CI211.
COMP s1 Computing 2 Complexity
Towers of Hanoi. Introduction This problem is discussed in many maths texts, And in computer science an AI as an illustration of recursion and problem.
A Review of Recursion Dr. Jicheng Fu Department of Computer Science University of Central Oklahoma.
Chapter 13 Recursion. Topics Simple Recursion Recursion with a Return Value Recursion with Two Base Cases Binary Search Revisited Animation Using Recursion.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
Sorting HKOI Training Team (Advanced)
Analysis of Algorithms
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 19 : Recursion King Fahd University of Petroleum & Minerals College of Computer.
1 Chapter 13 Recursion. 2 Chapter 13 Topics l Meaning of Recursion l Base Case and General Case in Recursive Function Definitions l Writing Recursive.
10/14/2015cosc237/recursion1 Recursion A method of defining a concept which refers to the concept itself A method of solving a problem by reducing it to.
224 3/30/98 CSE 143 Recursion [Sections 6.1, ]
Advanced Functional Programming 2009 Ulf Norell (lecture by Jean-Philippe Bernardy)
CSE 501N Fall ‘09 12: Recursion and Recursive Algorithms 8 October 2009 Nick Leidenfrost.
Data Structures R e c u r s i o n. Recursive Thinking Recursion is a problem-solving approach that can be used to generate simple solutions to certain.
Algorithms and their Applications CS2004 ( ) Professor Jasna Kuljis (adapted from Dr Steve Swift) 6.1 Classic Algorithms - Sorting.
Lecture 2 – MapReduce: Theory and Implementation CSE 490h – Introduction to Distributed Computing, Winter 2008 Except as otherwise noted, the content of.
TIVDM2Functional Programming Language Concepts 1 Concepts from Functional Programming Languages Peter Gorm Larsen.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
Lee CSCE 314 TAMU 1 CSCE 314 Programming Languages Haskell: Higher-order Functions Dr. Hyunyoung Lee.
CMSC 330: Organization of Programming Languages Maps and Folds Anonymous Functions.
1 Recursion. 2 Chapter 15 Topics  Meaning of Recursion  Base Case and General Case in Recursive Function Definitions  Writing Recursive Functions with.
CMSC 330: Organization of Programming Languages Operational Semantics a.k.a. “WTF is Project 4, Part 3?”
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
CS 206 Introduction to Computer Science II 10 / 10 / 2008 Instructor: Michael Eckmann.
0 PROGRAMMING IN HASKELL Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources) Odds and Ends,
Chapter 9 Recursion © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
Recursion ITI 1121 N. El Kadri. Reminders about recursion In your 1 st CS course (or its equivalent), you have seen how to use recursion to solve numerical.
Haskell Chapter 5, Part II. Topics  Review/More Higher Order Functions  Lambda functions  Folds.
CS 116 Object Oriented Programming II Lecture 13 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
CSC 143 P 1 CSC 143 Recursion [Chapter 5]. CSC 143 P 2 Recursion  A recursive definition is one which is defined in terms of itself  Example:  Compound.
CSE 3302 Programming Languages Chengkai Li Spring 2008 Functional Programming Language: Haskell (cont’d) Lecture 20 – Functional Programming, Spring 2008.
CSE202: Introduction to Formal Languages and Automata Theory
How to Parallelize an Algorithm
6.001 Jeopardy.
Introduction to Functional Programming in Racket
Learning to Program in Python
Intro to Data Structures
Distributed System Gang Wu Spring,2018.
Introduction to Functional Programming in Racket
CSE 3302 Programming Languages
Announcements Quiz 5 HW6 due October 23
Theory of Computation Lecture 4: Programs and Computable Functions II
Presentation transcript:

Problem-solving on large-scale clusters: theory and applications Lecture 1: Introduction and Theoretical Background

Today’s Outline Introductions Quiz Course Objective & Administrative Info fold and map : Theory

Introductions Name + trivia

Quiz Time! Not graded; helps us calibrate how difficult to make this seminar Okay (and encouraged!) to leave questions blank

Course Outline Introduction to parallel programming and distributed system design –successfully decompose problems into map and reduce stages –decide whether a problem can be solved with a parallel algorithm, and evaluate its strengths and weaknesses –understand the basic tradeoffs and major issues in distributed system design –know the common pitfalls of distributed system design This seminar is light on “facts” and “recipes”, heavy on “tradeoffs”

Course Information (1 of 2) Lecturers: –Albert J. Wong –Hannah Tang Lab consultant: –Alden King Liasons: –John Zahorjan –Christophe Bisciglia

Course Information (2 of 2) Textbook –None; see online course readings Webpage: Mailing lists: –Course discussion:

Warning: Theory Ahead! Before we can talk about MapReduce, we need to talk about the concepts on which it is founded: –Programming languages: fold and map –Distributed systems: data dependancies

Digression: Function Objects (1 of 3) A function object is a function that can be manipulated as an object –Sometimes referred to as a “functor” In Java, this is usually implemented with a class that has an execute() (or similarly named) method

class ReverseAlphaOrder implements Comparable { public int Compare(Object o1, Object o2) { if(o1 instanceof String && o2 instanceof String) { return String(o1) >= String(o2); } String[] myStrings; ReverseAlphaOrder rao; Collections.sort(myStrings, rao); Digression: Function Objects (2 of 3) Example: Inheriting from the Comparable interface to use Collections.sort() The underlying idea is to pass the “greater than” operation to sort()

Digression: Function Objects (3 of 3) In Java, methods that take function objects are “higher-order functions” –Collections.sort() is a higher-order function Mathematically, a “higher order function” is a function which does at least one of the following: –Take one or more functions as input –Output a function Examples: –The derivative (from calculus) d/dx (x 3 + 2x) = 3x 2 + 2

fold - Introduction fold is a family of higher-order functions that process a data structure and return a single value –Commonly, fold takes a function f and a list l, and recursively applies f to “combine” the elements of l –The return value may be “complex”, e.g. a list Example: –fold (+) [1,2,4,8] -> ??? –fold (/) [64,8,4,2] -> ???

fold - Directionality Remember how we said fold was “a family of functions”? –foldr (/) [64,8,4,2] -> 64 / (8 / (4/2)) -> 16 –foldl (/) [64,8,4,2] -> ((64/8) / 4) / 2 -> 1 “fold right” –recursively applies f over the right side of the list “fold left” –recursively applies f over the left side of the list Right foldLeft fold ÷ ÷ 2 ÷ 4 8 ÷ ÷ 2 ÷

fold - Questions Discussion questions: –What should the base case return? foldr (+) [] -> ??? foldr (/) [] -> ??? –Can a right fold be implemented as a loop (using tail recursion)? What about left fold? Enrichment questions: –What happens to a right fold when given an infinite list? What about left fold?

fold - Formal Definition fold takes a function and a list as its inputs – but it can also take more values. –In particular, fold maintains context / state across each invocation of f -- If the list is empty, return the initial value ‘z’ foldr f z [] = z -- If the list is not empty, calculate the result of folding the -- rest, and apply f to the first element and to that result. -- The context from previous invocations of f is implicitly -- passed to the current invocation of via foldr foldr f z (x:xs) = f x (foldr f z xs) What is the formal definition of foldl ?

fold – An Intuition fold “iterates” over a data structure, and maintains one unit of state –At each iteration, f is invoked with the current element and the current state –fold ’s return value is the result of f ’s final invocation

map - Introduction map is a higher-order function that “transforms” each element in a sequence of elements –Commonly, map takes a function f and a sequence s, and applies f to each element of s Example: –map square_root [1,4,9,16] -> ???

map ’s Return Value map returns a sequence –The new sequence s’ is not necessarily the same size as s –The elements of s’ do not necessarily have the same type as the elements of s

Recall that the sum of N vectors was equal to the sum of their components: Let components() decompose a vector into its X and Y components map ’s Return Value – Example a b a+b map components [ ] =,, ), (,,, = [ () ] ???,,,,, = [ ] ???

map - Questions Enrichment questions: –For what values of f and z will fold f z l = l ? How can you modify f such that fold f z l = map f l ? –Bonus question: can you implement map in terms of fold? –Visit foldl.com and foldr.com :)

map – Formal definition map takes a function and a data structure as its inputs -- If the list is empty, there’s nothing to do map f [] = [] -- If the list is not empty, apply f to the first element and -- add the result to the mapping of f on all other elements map f (x:xs) = f x : map f xs What is the complexity of map ? What is its runtime?

Exercise (1 of 2) Individually: –Determine how these operations can be solved with a fold, a map, or some combination of fold and map : Given a list of vectors, add them to determine the resultant vector. Ray tracing a single ray –Ray tracing takes a list of rays that intersect the camera, and traces their path back to their respective lightsources, even across their reflection over several surfaces Assuming you had access to a company’s monthly paystubs for all employees for an entire year, calculate how much annual income tax is owed per-person. Run-length encoding. –Run-length encoding takes a possibly-repetitive string and rewrites it as a (value, frequency) pair, eg “aaa b ccccc dd” -> “a3 b c5 d2”. Find the smallest element in an array –Come up with some challenging problems yourself!

Exercise (2 of 2) In small groups, compare your answers to the above, and stump your team with the problems you came up with!