algorithm engineering
play

Algorithm Engineering (aka. How to Write Fast Code) CS26 S260 - PowerPoint PPT Presentation

Algorithm Engineering (aka. How to Write Fast Code) CS26 S260 Lecture cture 10 Yan n Gu Algorithm Engineering and Graph Processing systems What is algorithm engineering CS260: Algorithm Graphs Engineering Lecture 10 Graph


  1. Algorithm Engineering (aka. How to Write Fast Code) CS26 S260 – Lecture cture 10 Yan n Gu Algorithm Engineering and Graph Processing systems

  2. What is algorithm engineering CS260: Algorithm Graphs Engineering Lecture 10 Graph processing systems 2

  3. Overall Structure in this Course Performance Engineering Algorithm Engineering Parallelism Sorting / Semisorting I/O efficiency Matrix multiplication New Bentley rules Graph algorithms Brief overview of architecture Geometric algorithms

  4. What is Algorithm Engineering? O(n log n) O(n) O(log n) Theory Practice • For many decades, theory and practice are two separate areas • Theory studies computability (e.g., complexity classes) • Writing faster codes was done the system community • Almost every undergrads know the algorithms with best bounds for classic problems such as SCC, sorting, connectivity, convex hull • Research is mostly about specific input instances, detail tuning, on HPCs

  5. What is Algorithm Engineering? O(n log n) O(n) O(log n) Theory Practice • No longer the case in the past decades since computer architecture becomes significantly more sophisticated • Parallelism, I/O efficiency, new hardware such as non-volatile memories

  6. Bridging Theory and Practice O(n log n) O(n) O(log n) • Good empirical performance • Confidence that algorithms will perform well in many different settings • Ability to predict performance (e.g. in real-time applications) • Important to develop theoretical models to capture properties of technologies Use theory to inform practice and practice to inform theory.

  7. What is Algorithm Engineering? • Algorithm design • Algorithm analysis • Algorithm implementation • Optimization • Profiling • Experimental evaluation O(n log n) O(n) O(log n) Theory Practice Source: MIT 6.886 by Julian Shun

  8. What is Algorithm Engineering? Source: “Algorithm Engineering – An Attempt at a Definition”, Peter Sanders Source: MIT 6.886 by Julian Shun

  9. Algorithm Design & Analysis Algorithm 1 Algorithm 2 N log 2 N 1000 N Complexity • Constant factors matter! • Avoid unnecessary computations • Simplicity improves applicability and can lead to better performance • Think about locality and parallelism • Think both about worst-case and real-world inputs • Use theory as a guide to find practical algorithms • Time vs. space tradeoffs Source: MIT 6.886 by Julian Shun

  10. Implementation • Write clean, modular code • Easier to experiment with different methods, and can save a lot of development time • Write correctness checkers • Especially important in numerical and geometric applications due to floating-point arithmetic, possibly leading to different results • Save previous versions of your code! • Version control helps with this Source: MIT 6.886 by Julian Shun

  11. Experimentation • Instrument code with timers and use performance profilers (e.g., perf, gprof, valgrind) • Use large variety of inputs (both real-world and synthetic) • Use different sizes • Use worst-case inputs to identify correctness or performance issues • Reproducibility • Document environmental setup • Fix random seeds if needed • Run multiple timings to deal with variance Source: MIT 6.886 by Julian Shun

  12. Experimentation II • For parallel code, test on varying number of processors to study scalability • Compare with best serial code for problem • For reproducibility, write deterministic code if possible • Or make it easy to turn off non-determinism • Use numactl to control NUMA effects on multi-socket machines Source: MIT 6.886 by Julian Shun

  13. What is Algorithm Engineering? • Algorithm design • Algorithm analysis • Algorithm implementation • Optimization • Profiling • Experimental evaluation O(n log n) O(n) O(log n) Theory Practice Source: MIT 6.886 by Julian Shun

  14. What is algorithm engineering CS260: Algorithm Graphs Engineering Lecture 10 Graph processing systems 14

  15. What is a graph? Edge Vertex Vertex • Ve Vertic ices s model l (a set of) objects ts • Edge ges model el rela latio ionship nships between een objects ts Carol David Alice Bob Eve Fred Greg Julian https://commons.wikimedia.org/wiki/File:Protein_Interaction_Netw Hannah ork_for_TMEM8A.png Source: MIT 6.172 by Julian Shun

  16. Social networks Source: MIT 6.172 by Julian Shun

  17. Collaboration networks Erdős number: Number of hops to Erdős via collaboration Source: MIT 6.172 by Julian Shun

  18. Transportation networks Source: MIT 6.172 by Julian Shun

  19. Computer networks Source: rawbytes.com Source: MIT 6.172 by Julian Shun

  20. Biological networks • Protein in-pr prote tein in in interac actio tion n (PPI) ) networ orks

  21. Other Applications • Biolo ological gical netwo tworks rks • Finan nancial cial transaction ansaction netwo tworks rks • Econom nomic ic trad ade e netwo tworks rks • Fo Food od web web • Vario rious us types es of biological ological networ works ks • Imag mage e segmen gmentation tation in n computer puter vi vision sion • Scien ientific tific simul mulations ations • Many more… Source: MIT 6.172 by Julian Shun

  22. What is a graph? • Edge ges can be dir irected ed / u undire irecte cted • Relationship can go one way or both ways http://www3.nd.edu/~dwang5/courses/spring15/assignments/A1/ http://farrall.org/papers/webgraph_as_content.html Assignment1_SocialSensing.html Source: MIT 6.172 by Julian Shun

  23. What is a graph? • Edge ges can be weig ighted ed / u unwe weighte ighted d (uni nit t weig ighted) ed) • Denotes “strength”, distance, etc. Distance between cities Flight costs https://msdn.microsoft.com/en-us/library/aa289152(v=vs.71).aspx Source: MIT 6.172 by Julian Shun

  24. What is a graph? • Ve Vertic ices s and edge ges s can have e types s and d metada data ta Google Knowledge Graph http://searchengineland.com/laymans-visual-guide-googles-knowledge-graph-search-api-241935 Source: MIT 6.172 by Julian Shun

  25. Social network queries http://www.facebookfever.com/introducing-facebook-new-graph- http://allthingsgraphed.com/2014/10/16/your-linkedin-network/ api-explorer-features/ • Ex Examples: ples: • Finding all your friends who went to the same high school as you • Finding common friends with someone • Social networks recommending people whom you might know • Advertisement recommentations Source: MIT 6.172 by Julian Shun

  26. Transportation network queries • Ex Examples: ples: • Find the cheapest way traveling from one city to the other • Decide where to build a hub/add a flight to make more profit • Find the shortest way to visit a set of locations (e.g., postman) Source: MIT 6.172 by Julian Shun

  27. Biological network queries • Example: ple: • Find patterns in biological networks • Find similarity between different species Source: UCR CS 260 (214) by Yihan Sun

  28. Graph Problems Reachability based Distance based Other Breadth-first search (BFS) Minimum spanning forest / Maximal independent Connectivity tree (undirected) set (MIS) Biconnectivity Single-source shortest-paths Matching Undirected Spanning forest (SSSP) Graph coloring Low-diameter All-pair shortest-paths Coreness decomposition (LDD) (APSP) Isomorphism Betweenness centrality (BC) Spanner / Hopset Strongly Connected Page rank Directed Components (SCC)

  29. Graph Problems Reachability based Distance based Other Breadth-first search (BFS) Minimum spanning forest / Maximal independent Connectivity tree (undirected) set (MIS) Biconnectivity Single-source shortest-paths Matching Undirected Spanning forest (SSSP) Graph coloring Low-diameter All-pair shortest-paths Coreness decomposition (LDD) (APSP) Isomorphism Betweenness centrality (BC) Spanner / Hopset Strongly Connected Page rank Directed Components (SCC) • Pla lanar ar gr graphs hs (gr graphs hs that can be drawn n on a p pla lain in) • Dynamic amic gr graphs hs (ca can ch change ge over r tim ime)

  30. Real-world graph sizes in 2019 Graph Num. Vertices Num. Undirected Edges soc-LiveJournal 4.8M 85M com-Orkut 3M 234M Twitter 41M 2.4B Facebook (2011) [1] 721M 68.4B Hyperlink2014 [2] 1.7B 124B Hyperlink2012 [2] 3.5B 225B Facebook (2018) > 2B > 300B Yahoo! 272B 5.9T Google (2018) > 100B 6T Brain Connectome 100B (neurons) 100T (connections) : Publicly available graphs [1] The Anatomy of the Facebook Social Graph, Ugander et al. 2011 [2] http://webdatacommons.org/hyperlinkgraph/ : Private graph datasets 30 Source: CMU 15-853 by Laxman Dhulipala

  31. Graph Representation 31

  32. 𝑜 = # of vertices Graph Representations 𝑛 = # of edges • Ve Vertic ices s la labele led d from 0 t to n n-1 1 2 3 4 0 (0,1) (1,0) 0 0 1 0 0 0 (1,3) O(n 2 ) 1 0 0 1 1 O(m) 1 (1,4) 0 0 0 1 0 2 (2,3) (3,1) 0 1 1 0 0 3 (3,2) 0 1 0 0 0 4 (4,1) Adjacency matrix (“1” if edge exists, Edge list “0” otherwise) • Space? Source: MIT 6.172 by Julian Shun

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend