Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 303 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
303
Dung lượng
13,3 MB
Nội dung
[...]... consider the case where Process 1 (P1) requires a vector of values from Process 0 (P0) The program running as P0 must include logic to package the vector into a buffer and call the function that will send the contents of that buffer from the memory ofthe node on which P0 is running across the network connection between the nodes and deposit the buffer contents into the memory ofthe node running P1 On the. .. already designed and written, the functionality ofthe application is known You should also know which outputs are generated for given inputs Now you need to find the parts ofthe code that can be threaded; that is, those parts ofthe application that contain independent computations If you know the application well, you should be able to home in on these parts ofthe code rather quickly If you are less... the same location, the order ofthe updates to the memory location will determine the value that is ultimately stored there and the value that will be read out ofthe location by another thread (recall the airline reservation system that put two passengers in the same seat) When you have one thread reading and one thread writing to the same memory location, the value that is being read can be one of. .. of these have focused on message-passing as the method of parallelization Some ofthe earlier texts detail algorithms where the network configuration (e.g., mesh or hypercube) is an integral part ofthe algorithm design; later texts tend not to focus so much on developing algorithms for specific network configurations, but rather, think ofthe execution platform as a cluster of processor nodes In the. .. to another, while static allocation will always assign the same work to the same threads (if the number of threads is the same) each and every time 16 CHAPTER 1: WANT TO GO FASTER? RAISE YOUR HANDS IF YOU WANT TO GO FASTER! Typically, if the work can be broken up into a number of parts that is equal to the number of threads/processes, and the execution time is roughly the same for each of those parts,... writes a value into a memory location and the other thread reads the value out of that memory location Of course, to ensure that the data is transferred correctly, the writing thread must deposit the value to be shared into memory before the reading thread examines the location Thus, the threads must synchronize the order of writing and reading between the threads The send-receive exchange is an implicit... able to find these kinds of errors with any tool that looks for threading errors, but you may be able to home in on the problem with the use of some sort of debugging tool One ofthe minor themes of this book is the typical logic errors that can be introduced around threaded code and how to avoid these errors in the first place With a good solid design, you should be able to keep the number of threading... serially When the results of those serial computations must be shared, you can perform the computation in one process and broadcast the results out to the other processes that require the data Sending this information will add overhead to the execution time On the other hand, if the data used in the computation is already available to other processes, you can have each process perform the computation... users of the software to find out what functionality is desired, what the input and output specifications are, and, based on the feedback, formally specify the functionality to be included, a general structure ofthe application, and the code to implement it Design Set down more detailed plans ofthe application and the functional components ofthe application Implement Write the code for the application... to improve the execution time A maintenance step is not part ofthe threading methodology I assume that once you have an application written, serial or concurrent, that application will be maintained as part ofthe normal course of business The four steps ofthe threading methodology are considered in more detail in the following sections Step 1 Analysis: Identify Possible Concurrency Since the code . y0 w0 h1" alt=""
The Art of Concurrency
Clay Breshears
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Taipei
•
Tokyo
The Art of Concurrency
by Clay. Edition.
O’Reilly and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc.
The Art of Concurrency
, the
image of wheat-harvesting combines,