{"id":189,"date":"2008-12-22T16:54:46","date_gmt":"2008-12-22T21:54:46","guid":{"rendered":"http:\/\/vgable.com\/blog\/2008\/12\/22\/how-to-multi\/"},"modified":"2008-12-22T16:54:49","modified_gmt":"2008-12-22T21:54:49","slug":"how-to-multi","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2008\/12\/22\/how-to-multi\/","title":{"rendered":"How To Multi"},"content":{"rendered":"<blockquote><p> <strong>Avoid distributed computing unless your code is going to be run by a single client with a lot of available hardware.<\/strong> Being able to snarf up CPU cycles from idle hardware sitting around in the user&#8217;s house sounds cool but just doesn&#8217;t pay off most of the time.<\/p>\n<p><strong>Avoid GPGPU on the Mac until Snow Leopard ships<\/strong> unless you have a really good application for it. OpenCL will make GPGPU a lot more practical and flexible, so trying to shoehorn your computationally expensive code into GLSL or CoreImage today just doesn&#8217;t seem worth it.<\/p>\n<p><strong>Using multiple processes is a good idea if the subprograms are already written. &#8230; If you&#8217;re writing your code from scratch, I don&#8217;t recommend it<\/strong> unless you have another good reason to write subprocesses, as it&#8217;s difficult and the reward just isn&#8217;t there.<\/p>\n<p><strong>For multithreading, concentrate on message passing and operations.<\/strong> Multithreading is never easy, but these help greatly to make it simpler and less error prone.<\/p>\n<p><strong>Good OO design will also help a lot here.<\/strong> It&#8217;s vastly easier to multithread an app which has already been decomposed into simple objects with well-defined interfaces and loose coupling between them.<\/p><\/blockquote>\n<p>&#8212;<a href=\"http:\/\/www.mikeash.com\/?page=pyblog\/friday-qa-2008-12-19.html\">Mike Ash<\/a> (emphasis mine, line-breaks added).  <a href=\"http:\/\/www.mikeash.com\/?page=pyblog\/friday-qa-2008-12-19.html\">The article has more detail and is very much worth reading<\/a>.<\/p>\n<p>One point that this advice really drives home for me is that <strong>you need to focus on making good code first, and defer micro-optimizations<\/strong>.  If taking the time to clean up some code makes it easier to parallelize, then you <em>are<\/em> optimizing your code by refactoring it, even if at a micro-level you might be making some of it slower by, say, not caching something that takes O(1) time to compute.<\/p>\n<p>Apple does not sell a Mac that&#8217;s not multi-core, and even the iPhone has a CPU <em>and<\/em> a GPU. There&#8217;s no question that optimization means parallelization.  And all signs point to computers getting more parallel in the future.  Any optimization that hurts parallelization is probably a mistake.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Avoid distributed computing unless your code is going to be run by a single client with a lot of available hardware. Being able to snarf up CPU cycles from idle hardware sitting around in the user&#8217;s house sounds cool but just doesn&#8217;t pay off most of the time. Avoid GPGPU on the Mac until Snow [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6,3,5,4,24],"tags":[265,117,259,158,266,29],"class_list":["post-189","post","type-post","status-publish","format-standard","hentry","category-c","category-cocoa","category-macosx","category-objective-c","category-programming","category-quotes","tag-distributed-computing","tag-futurism","tag-multi-core","tag-optimization","tag-parallelization","tag-threads"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":0,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}