4 Pages

Midterm1-2010

Course: CS 140, Spring 2011
School: UCSB
Rating:
 
 
 
 
 

Word Count: 888

Document Preview

140 CS Midterm 1 -- 8 February 2010 Name Perm# Problem 1 [20 points total] In Lake Wobegon, all the women are strong, all the men are goodlooking, and all the children are above average. Well, everyone cant be above average--but here well count how many are. We have n kids and p processors. Each processor starts out with n/p elements of a vector IQ of the n kids IQ values. Your goal is to compute the average of...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> UCSB >> CS 140

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
140 CS Midterm 1 -- 8 February 2010 Name Perm# Problem 1 [20 points total] In Lake Wobegon, all the women are strong, all the men are goodlooking, and all the children are above average. Well, everyone cant be above average--but here well count how many are. We have n kids and p processors. Each processor starts out with n/p elements of a vector IQ of the n kids IQ values. Your goal is to compute the average of all n IQs (that is, their sum divided by n), and also to figure out how many of the n IQs are larger than average. The results, called averageIQ and numHighIQ, should end up on processor 0. For example, if the entries in IQ[] are 110, 90, 120, and 100, then the averageIQ is 420 / 4 = 105, and the numHighIQ is 2 (since two values, 110 and 120, are larger than average). A sequential algorithm to do this on one processor would be as follows. Note that IQ[] and averageIQ are doubles, not integers. double sum = 0; for (int i = 0; i < n; i++) sum += IQ[i]; double averageIQ = sum / n; int numHighIQ = 0; for (int i = 0; i < n; i++) if (IQ[i] > averageIQ) numHighIQ ++; For this problem only, you dont have to worry about the efficiency of your code. (1a) [10 points] Using pseudo-code, show how to do this in MPI using send and recv. (1b) [10 points] Using pseudo-code, show how to do this in MPI using broadcast and reduce. Name Perm# Problem 2 [20 points total] This problem compares two different data layouts for matrix-vector multiplication on a message-passing machine. All n elements of a vector x are on processor 0. The elements of an n-by-n array A are divided evenly among p processors, with n2/p elements per processor. The goal is to have all n elements of the product A*x end up on processor 0. For Algorithm 1, each processor has n/p rows of A. For Algorithm 2, each processor has a square block of A with n/sqrt(p) rows and n/sqrt(p) columns. Assume that n is divisible by p, and that p is a perfect square. You dont have to show the code for the two algorithms; just answer these questions. (2a) [2 points] Draw a clearly labeled diagram of the data layout for Algorithm 1. (2b) [2 points] Draw a clearly labeled diagram of the data layout for Algorithm 2. (2c) [15 points] Complete the following table with the parallel time tp , the span t , and the total communication volume v for each algorithm. For t, we count only multiplication operations (which is why the work t1 is n2). You can omit lower-order terms in your answer, for example by writing n2 instead of something like n2 n + 1. Work t1 Parallel tp Span time t Comm volume v Algorithm 1 n2 n2 / p Algorithm 2 n2 Name Perm# Problem 3 [20 points] Suppose you have p processors, P(0) through P(p-1), each with local (double) variables x, y, and d (plus any other local variables you need). Each (x, y) represents a point in the plane, so each processor has one point. The goal is for each processor to set its own d to the shortest distance between its point and any other processors point. For example, if there are three processors with points P(0): x = 1, y = 1 P(1): x = -1, y = 0 P(2): x = 0, y = 0 P1 y P0 P2 x then (1,1)s closest point is (0,0), and (-1,0)s closest point is (0,0), and (0,0)s closest point is (-1,0), so the result should be P(0): d = sqrt(2) P(1): d = 1 P(2): d = 1 Write message-passing code (pseudocode is fine) to achieve this. Rules: Use *blocking* send and receive calls for all communication. Each processor P(i) should only send to / receive from its neighbors P(i-1) and P(i+1), where we also include P(p-1) and P(0) as neighbors of each other. For full credit, your algorithm should use no more than 2p rounds of message-passing, and should have parallel computation time tp = O(p). Hint: Send copies of all the processors (x, y) values around a merry-go-round ring. (Note: Its an interesting problem in computational geometry to do this in *less* than O(p) parallel time; but you dont have to do that for the exam problem.) Name Perm# Problem 4 [20 points total] You have a function called findmax that computes the largest element in an array of size n = 2k. The serial version of your code looks like the following: double findmax(double * array, int n) { double max = array[0]; for (int i = 1; i < n; i++) if (array[i] > max) max = array[i]; return max; } (4a) [10 points] Explain briefly why you cant parallelize this function in cilk++ by just changing the for loop to a cilk_for. Give a small example (say n = 3 or 4) of what can go wrong. (4b) [10 points] Describe a way to parallelize this function using cilk_spawn. (You dont have to write syntactically correct cilk++ code, just be sure your description is clear.) Problem 5 [20 points total] Short answer questions. (5a) [10 points] What is an embarrassingly parallel problem? Give an example. (5b) [10 points] A sequential program spends 99% of its time on a computation that could be done efficiently in parallel, and the other 1% on a computation that cant be parallelized at all. What can you say about maximum speedup for a parallel version of this program?
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UCSB - CS - 140
Complexity Measures for Parallel ComputationSeveral possible models! Several Execution time and parallelism: Work / Span Model Total cost of moving data: Communication Volume Model Detailed models that try to capture time for moving data: Latency / Band
UCSB - CS - 140
Parallel Computers Today ParallelTwo Nvidia 8800 GPUs&gt; 1 TFLOPSOak Ridge / Cray Jaguar&gt; 1.75 PFLOPSIntel 80core chip&gt; 1 TFLOPS TFLOPS = 1012 floating point ops/sec PFLOPS = 1,000,000,000,000,000 / sec (1015)Supercomputers 1976: Cray-1, 133 MFLOPS
UCSB - CS - 140
CS 140 : Matrix multiplication CS Matrix multiplication I : parallel issues Matrix multiplication II: cache issuesThanks to Jim Demmel and Kathy Yelick (UCB) for some of these slidesCommunication volume model Communication Network of p processors Eac
UCSB - CS - 140
Hello, world in MPI Hello,#include &lt;stdio.h&gt; #include &quot;mpi.h&quot; int main( int argc, char *argv[]) cfw_ int rank, size; MPI_Init( &amp;argc, &amp;argv ); MPI_Comm_size( MPI_COMM_WORLD, &amp;size ); MPI_Comm_rank( MPI_COMM_WORLD, &amp;rank ); printf( &quot;Hello world from proce
UCSB - CS - 140
CS 140 : Jan 31 Feb 7, 2011 Multicore (and Shared Memory) Programming with Cilk+ Multicore and NUMA architectures Multithreaded Programming Cilk+ as a concurrency platform Divide and conquer paradigm for Cilk+Thanks to Charles E. Leiserson for some of t
UCSB - CS - 140
www.cilk.com How to Survive the Multicore Software Revolution (or at Least Survive the Hype)CharlesE.Leiserson IlyaB.Mirman Pagei www.cilk.comContentsPreface. iv 1. TheEmergenceofMulticoreSoftware. 1 Thefreelunchisover. 1 Themulticoresoftwaretria
UCSB - CS - 140
January 21, 2011Administrivia Expectations and Confidence Homework #1 Homework #2 Moving forward Read the materials provided. If you need help come work with me!Hw1 MPI Communicationvoid powerMethod(int dims[2], double* splitA, double* x, int my_rank
UCSB - CS - 140
+Game of Life!February 11, 2011+ Administrivia Midterms Soon Hw4 Soon Watch Jeopardy!+ Today Talk about the basic concepts behind the game of life. Look at the Matlab code to get some ideas. Discuss possible parallelization strategies. What the he
UCSB - CS - 165A
Artificial IntelligenceCS 165AJan 4, 2011 Prof. Xifeng YanComputer Science Science1What is Artificial Intelligence? AI in the media Popular movies 2001: A Space Odyssey Star Trek Star Wars The Terminator The Matrix Popular press, novels Often port
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Thursday, Jan 06, 2011 Finish AI overview AI overview Some material from Ch. 26 Intelligent agents (Ch. 2)1Notes Lecture notes Username: cs165a Password: winter20112Review What is Artificial Intelligence? What
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Thursday, Jan 13, 2011 Basic Search (Ch. 3) Search (Ch 3)1Notes Lecture notes Username: cs165a Password: winter2011 Homework 1 posted; due by Jan 20 before the class. Tomorrow (Jan 14) Makeup Class,2Review Wha
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Friday, Jan 14, 2011 Basic Search (Ch. 3) Search (Ch 3)1Notes Lecture notes Username: cs165a Password: winter2011 Homework 1 due by Thursday 2 pm.2Review Problem formulation and search State-space description
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Tuesday, Jan 18, 2011 Informed Search (Ch. 3) Search (Ch1Notes Lecture notes Username: cs165a Password: winter20112Review Uninformed Search Breadth First Depth First Uniform Cost Depth Limited Limited Iterativ
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Thursday, Jan 20, 2011 Advanced Search (Ch. 4) Search (Ch 4)1Notes Lecture notes Username: cs165a Password: winter20112Review Optimality of A* Let OPT be the optimal path cost. OPT be the optimal path cost All
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Tuesday, Jan 25, 2011 Adversarial search (Ch. 5) search (Ch 5)1Announcements Homework 2 posted; due by Feb 1 before the class Machine Problem will be posted this Thursday Problem will be posted this Thursday2Mach
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Thursday, Jan 27, 2011 Knowledge and reasoning (Ch. 7) and reasoning (Ch1Notes HW#2 due next Tuesday MP specification will be out tomorrow (Jeff is working on specification will be out tomorrow (Jeff is working on
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Tuesday Feb 2, 2011 First order logic (Ch. 8) order logic (Ch 8)1Notes HW#3 is out, which will be due next Tuesday To reduce the workload, HW #3 only has two questions reduce the workload HW #3 only has two questio
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Thursday, Feb 03, 2011 First order logic (Ch. 8) order logic (Ch 8) Inference (Ch. 9)1Notes HW#3 due next Tuesday Midterm next Thursday next Thursday2Simple example of inference in FOLBob is a buffalo Pat is a p
UCSB - CS - 165A
Artificial IntelligenceCS 165A 165A Tuesday, Feb 8, 2011 Inference (Ch. 9) (Ch 9)1Notes Midterm, this Thursday One Hour Close Book2What weve been talking about Complete and sound inference procedures New inference rules: inference rules: Univers
UCSB - CS - 165A
CS 165A Articial Intelligence, Winter 2011, Assignment #3 Propositional LogicDue before class on February 8, 2011Notes Be sure to re-read the Policy on Academic Integrity on the course syllabus. Any updates or corrections will be posted on the Announce
UCSB - CS - 165A
CS 165A Artificial Intelligence, Winter 2011 Assignment #1 Artificial Intelligence Due Thursday, Jan 20 before the classNotes: Be sure to re-read the Policy on Academic Integrity on the course syllabus. Any updates or corrections will be posted on the
UCSB - CS - 165A
v. 1.0CS 165A Artificial Intelligence, Winter 2011 Assignment #2 Problem Solving and Search Due Tuesday, February 01 before the classNotes: Be sure to re-read the Policy on Academic Integrity on the course syllabus. Any updates or corrections will be
UCSB - CS - 165A
CS 165A Artificial Intelligence, Winter 2011 Assignment #4 First-order logic Due Thursday, Feb 24 before the classNotes: Be sure to re-read the Policy on Academic Integrity on the course syllabus. Any updates or corrections will be posted on the Announ
UCSB - CS - 140
CS 140 Assignment 4:Cilkified Inner ProductsAssigned January 31, 2011Due by 11:59 pm Monday, February 7The purpose of this assignment is to gain familiarity with Cilk+ constructs and tools, as well as to think about different ways of parallelizing an
UCSB - ECE - 154
Part IBackground and MotivationJan. 2011Computer Architecture, Background and MotivationSlide 1About This PresentationThis presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercomputers, Oxf
UCSB - ECE - 154
Part IIInstruction-Set ArchitectureJan. 2011Computer Architecture, Instruction-Set ArchitectureSlide 1About This PresentationThis presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercompute
UCSB - ECE - 154
Part IIIThe Arithmetic/Logic UnitJan. 2011Computer Architecture, The Arithmetic/Logic UnitSlide 1About This PresentationThis presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercomputers, O
UCSB - ECE - 154
Part IVData Path and ControlFeb. 2009Computer Architecture, Data Path and ControlSlide 1About This PresentationThis presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercomputers, Oxford Uni
UCSB - ECE - 154
Part VMemory System DesignFeb. 2009Computer Architecture, Memory System DesignSlide 1About This PresentationThis presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercomputers, Oxford Univer
UCSC - BIOC - 100b
Bioc100BWinter 2011RubinProblem Set #1 Due Tuesday, January 11th 4:00 P.M.1) Size-exclusion chromatography is a technique that can be used to determine approximately the molecular weight of a protein, protein complexes, or simple protein mixtures in s
UCSC - BIOC - 100b
Bioc100BWinter 2011RubinSolution Set #31) Explain why in the symmetry model of allosterism, an inhibitor must have a positive homotropic effect on itself. Is this same behavior necessarily true of an allosteric inhibitor in the sequential model? The s
University of Colorado Denver - CHEM - 4591
CHEM4591 T 9-11:50am Feb 8th Weifeng Wang Partner: Zheng Zheng TA: Samuel ParkVibration-Rotation Spectrum of HClAbstract The vibration-Rotation spectrum of HCl was measured by the fundamental spectrum and overtone spectrum. The fundamental spectrum was
UPenn - CIS - 550
CIS 550 DatabasesVal TannenFall 2010Lecture Notes 01September 27, 2010 Slides courtesy of Susan Davidson, Zachary Ives &amp; Raghu RamakrishnanWhy This Course?Most CS courses concentrate on code our interest is managing and representing dataWarnin
Keller Graduate School of Management - AC - 594
Lucille McElroy: REG 3 10 ? M/C QuizPage 1 of 8Grade for Lucille McElroy: REG 3 10 ? M/C QuizNumeric grade: 30 Comments: (none) &lt;Close Window Autograde Summary These are the automatically computed results of your exam. Grades for essay questions, and c
Saddleback - PSYCHOLOGY - 310
Mohammad Abouayed 11/17/10 Stress MangAcute Stress Disorder &amp; HypnosisThe article is about a study that is set up to prove that the use of hypnosis in addition to CBT (cognitive behavioral therapy) is very beneficial in treating Acute stress disorder an
National University of Singapore - MKT - 3402
Individual Assignment GuidelinesConstrual Theory Click to edit Master subtitle style2/23/11Billboards Vs Print Ads Vs Mobile PhonesWhat are the fundamental differences between Billboards vs Print Ads? (Or billboards vs Mobile Phone)2/23/11Construal
SUNY Stony Brook - CSE - 336
Session 1 - IntroductionCSE 336Introduction to Programming for Electronic Commerce Robert Kelly, 2001-20101General Class Issues Dr. R. Kelly (contact info on class Web site) Hands-on class Trans lab Trans Text www readings (list on a page in class
SUNY Stony Brook - CSE - 336
Session 2 BackgroundSession 2Background1Lecture Objectives Understand how an Internet resource is accessed Understand the high level structure of the Internet cloud Understand the high level structure of the TCP/IP protocols Understand how a computer
SUNY Stony Brook - CSE - 336
Session 3 HTMLSession 3HTMLTim Berners-Lee1Reading WebReference tutorialswww.webreference.com/html/tutorials/ Wikien.wikipedia.org/wiki/Html Character setshttp:/scripts.sil.org/IWS-Chapter03/ Robert Kelly, 2001-201029/10/2010 Robert Kelly,
SUNY Stony Brook - CSE - 336
Session 4 CSSSession 4Style Sheets (CSS)1Reading Reading - Style Sheet Tutorialswww.htmldog.com/guides/cssbeginner/ - beginners guide www.westciv.com/style_master/academy/css_tutorial/index.html www.webreference.com/html/tutorials/ - Tutorials www.h
SUNY Stony Brook - CSE - 336
Session 5 Servlet IntroInternet Commerce ProgrammingSession 5Introduction to Servlets1Lecture Objectives Understand the popular approaches to generating HTML on a server Know how the Hello World servlet operates Understand the interaction among the
SUNY Stony Brook - CSE - 336
Session 6 FormsSession 6Form Dataset1Lecture Objectives Understand the relationship between HTML form elements and parameters that are passed to the servlet, particularly the form dataset Robert Kelly, 2001 - 201029/20/2010 Robert Kelly, 2001 - 2
SUNY Stony Brook - CSE - 336
Session 7 HttpSession 7Deployment Descriptor Http1Reading and Reference Readingen.wikipedia.org/wiki/HTTP Reference Table of deployment descriptorsdownload-llnw.oracle.com/docs/cd/E13222_01/wls/docs81/ webapp/web_xml.html http headersen.wikiped
SUNY Stony Brook - CSE - 336
Session 8 Java BeansSession 8JavaBeans1Reading &amp; Reference Reading Head First Chapter 3 (MVC) Reference JavaBeans Tutorialjava.sun.com/docs/books/tutorial/javabeans/ Robert Kelly, 2001-201029/27/2010 Robert Kelly, 2001-20101Session 8 Java Be
SUNY Stony Brook - CSE - 336
Session 9 Data SharingSession 9Data Sharing &amp; Cookies1Reading &amp; Reference Reading Chapter 5, pages 185-204 Reference http state managementwww.ietf.org/rfc/rfc2109.txt?number=2109 Robert Kelly, 2001-2010210/1/2010 Robert Kelly, 2001-20101Sess
SUNY Stony Brook - CSE - 336
Session 11 ELSession 11Expression Language (EL)1Reading Reading Head First pages 368-401 Sun Java EE 5 Chapter 5 in the Tutorialjava.sun.com/javaee/5/docs/tutorial/doc/JavaEETutorial.pdf Reference JSTL Reference (Chapter 3 and Appendix A) - link
SUNY Stony Brook - CSE - 336
Session 12 JSTLSession 12JSP Tag Library (JSTL)1Reading &amp; Reference Reading Head First Chap 9, pages 439-474 Reference (skip internationalization and sql sections) Java EE 5 Tutorial (Chapter 7) - link on CSE336 Web site (References Section) JavaW
SUNY Stony Brook - CSE - 336
Session 14 JSP Custom TagsSession 14JSP Custom Tags1Reading &amp; Reference Reading Head First Pages 476-490 Chapter 10 (pages 512-528, 576-577)Note that Head First covers both the JSP 2.0 approach and the classic approach this lecture covers mostly
SUNY Stony Brook - CSE - 336
Session 16 JavaScript (Part 1)Session 16JavaScript Part 11Reading Reading Wikipediaen.wikipedia.org/wiki/Javascript W3Cwww.w3.org/TR/REC-html40/interact/scripts.html Web Developers Noteswww.webdevelopersnotes.com/tutorials/javascript/ APIkroo
SUNY Stony Brook - CSE - 336
Session 17 JavaScript (Part 2)Session 17JavaScript Part 21W3C DOM Reading and Reference Background and introductionwww.w3schools.com/HTMLDOM/default.asp Reading a good tutorial on the use of W3C DOM to modify htmlwww.builderau.com.au/program/javas
SUNY Stony Brook - CSE - 336
Session 18 AjaxSession 18Ajax1Reading &amp; Reference Reading Sun Tutorialjava.sun.com/developer/technicalArticles/J2EE/AJAX/ Reference XMLHttpRequest objecten.wikipedia.org/wiki/Xmlhttprequest www.w3.org/TR/XMLHttpRequest/ JavaScript by David Flan
SUNY Stony Brook - CSE - 336
Session 19 JSP Access to XMLSession 19JSP Access to an XML Document XPath1Reading Reading JSTL (XML Tags Section)java.sun.com/developer/technicalArticles/javaserverpages/f aster/ today.java.net/pub/a/today/2003/11/27/jstl2.html XPathThis is a goo
SUNY Stony Brook - CSE - 336
Session 20 XSLTSession 20XML Transformations XSLT1Reading &amp; Reference Reading XML in a Nutshell (Chapter 8) Book chapter (XML Bible)www.ibiblio.org/xml/books/bible2/chapters/ch17.html XSLTwww-106.ibm.com/developerworks/library/x-xslt/ Reference
SUNY Stony Brook - CSE - 333
Usability of Interactive Systems1User InterfacesAt an individual level, user interfaces change many peoples lives Routine processes: online banking and bill payment, tax return preparation, e-prescription Decision support: doctors diagnosis and treatm
SUNY Stony Brook - CSE - 333
User-Centered Design1Waterfall ModelCharacterized by Feedback loops Testing and validation Documentation-drivenAdvantages Enforced disciplined approachDisadvantages I know this is what I asked for, but it isnt really what I wanted.21Waterfall M
SUNY Stony Brook - CSE - 333
User Interface Software Architecture1The Three CharacteristicsEvery GUI component has three characteristics Contents (state of a button, text in a text field, etc.) Visual appearance (color, size, etc.) Behavior (reaction to events)Complex interactio
SUNY Stony Brook - CSE - 333
Event Handling (Part 1)1Why Use Events for GUI Input?Console I/O uses blocking procedure calls System controls the dialogGUI input uses event handling User has much more control over the dialogue User can click on almost anything21Event Handling
SUNY Stony Brook - CSE - 333
Event Handling (Part 2)1Focus EventsWindow manager directs all keystrokes to the active window A component has focus if it can receive keyboard events Window: highlighted title bar Text field: blinking cursor Button: rectangle around labelOnly one co
SUNY Stony Brook - CSE - 333
Event Handling (Part 3)1Event HandlingOne event source and one event listenerButtonAction EventColorAction21Event HandlingMultiple ways to activate the same command link all the event sources to the same listener Menu item (Blue) Button (Blue)
SUNY Stony Brook - CSE - 333
Human Capabilities1Human CapabilitiesHuman information processing Perception Motor skills Memory Decision making Attention Vision21Human Information Processing3MemoriesMemory properties Encoding: type of things stored Size: number of things sto
SUNY Stony Brook - CSE - 333
Conceptual Models1ModelsA model of a system is a way of describing how the system works Its constituent parts and how they work together to do what the system is supposed to doImplementation models Pixel editing vs. structured graphicsInterface mod