CSE 633 Parallel Algorithms Fall 2010
Transcript of CSE 633 Parallel Algorithms Fall 2010
![Page 1: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/1.jpg)
CSE 633 Parallel Algorithms Fall 2010Computer Science and Engineering
University at Buffalo
John LonganeckerParallel Computing with Browsers
Bin Packing EditionNovember 4th, 2010
![Page 2: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/2.jpg)
Itinerary
• Description of the browser• Advantages• Disadvantages• How I plan to harness it• Packing Algorithm• Technologies used• Results• Scheduling
![Page 3: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/3.jpg)
Imagine..• Nearly 2 Billion computes worth of idle CPU Time
• Huge Potential
![Page 4: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/4.jpg)
Browsers
![Page 5: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/5.jpg)
Browsers
• HTML – Markup Language• HTML is not a programming language• One native scripting language JavaScript• Standards exists but not followed well
![Page 6: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/6.jpg)
Web Architecture
• Server side• Client side• Client enters website into the browser• Browser sends a request to the server• Server sends the information to the browser• Browser receives the information
![Page 7: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/7.jpg)
How Can WeUse this?
![Page 8: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/8.jpg)
How Can We Use This?
• The client visits a web page• Server sends the client instructions• The client side processes instructions with
JavaScript• Client sends back answers to the web server
![Page 9: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/9.jpg)
Additional Information
• Browsers are not made to do heavycomputations
• In fact they are made to stop heavycomputations
• Browsers become unresponsive• JavaScript is single threaded
![Page 10: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/10.jpg)
Browsers Stop Heavy Computation
![Page 11: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/11.jpg)
Web Workers
![Page 12: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/12.jpg)
Disadvantages of this Model
• Web Workers are new• Not widely supported• Internet Speed• Potential loss of computed results• JavaScript is Slow• Not good for real-time problem solving• Not dependable
![Page 13: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/13.jpg)
Advantages of this Model
• Multi-Platform• Easy to Use• No installation required just a browser• No installation• JavaScript is getting faster• Applications moving to browser• Could work on local network• Browsers to support hardware acceleration
![Page 14: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/14.jpg)
How Am IGoing toUse This?
![Page 15: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/15.jpg)
Bin Packing
![Page 16: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/16.jpg)
Packing Algorithm
http://www.blackpawn.com/texts/lightmaps/default.html
![Page 17: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/17.jpg)
Bin Packing
• Big bag of 3D boxes• Client will only see 2 dimensions• Client will get a bunch of boxes• Leftovers get sent back• Results sent back to server• Server will see all 3 Dimensions• Server will optimize for Height (3rd dimension)
![Page 18: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/18.jpg)
Data I am Using
• Unit: pixels• Client level size: 640 x 480• Box dimensions range from 1 to 8• Boxes are randomly generated• Probability is the same for all sizes
(Example 8 is as likely to be picked as 1)
![Page 19: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/19.jpg)
Technologies Used
• Server Side: PHP, MySQL (shared hosting)• Client Side: JavaScript (Chrome, Firefox)• Server Side: Why PHP and MySQL?• Client Side Why not Java or Flash?
![Page 20: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/20.jpg)
Problems: Height of Boxes Range
Pictured above is one level (what a client gets) from the side.We see the 3rd dimension. Clients only sees 2 Dimensions.
![Page 21: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/21.jpg)
Problems: Client Is Only Looking at2-Dimensions
Pictured above is one level (what a client gets). Here wesee a tightly packed level that the client has packed.
![Page 22: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/22.jpg)
Optimizing For 3 Dimensions
• Sort boxes so that the 3rd dimension is thesmallest side (height)
• Sort the boxes in the database query• Sort by the x value on the client side
![Page 23: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/23.jpg)
Results
![Page 24: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/24.jpg)
Scheduling
• Client receives a unique identifier• The client checks out 16,000 boxes• Boxes that have not been checked back in 3
minutes get put back into the pool• If the client refreshed their page within the 3
minute window, they get the same set of boxes• Each box has its own row in the database• Results set is written back to the database• Boxes are now flagged as being used and can
never be checked out again
![Page 26: CSE 633 Parallel Algorithms Fall 2010](https://reader033.fdocuments.us/reader033/viewer/2022052106/62880856337338671d50ffdb/html5/thumbnails/26.jpg)
References
• Packing Light Maps Algorithm:http://www.blackpawn.com/texts/lightmaps/default.html
• Bin Packing with JavaScripthttp://pollinimini.net/blog/rectangle-packing/