<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vincent Gable's Blog &#187; Multi-Core</title>
	<atom:link href="http://vgable.com/blog/tag/multi-core/feed/" rel="self" type="application/rss+xml" />
	<link>http://vgable.com/blog</link>
	<description>my weblog.</description>
	<lastBuildDate>Tue, 29 Nov 2011 22:20:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Arrow Points Up</title>
		<link>http://vgable.com/blog/2010/06/17/the-arrow-points-up/</link>
		<comments>http://vgable.com/blog/2010/06/17/the-arrow-points-up/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 13:03:40 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Quotes]]></category>
		<category><![CDATA[Abstraction]]></category>
		<category><![CDATA[Culture]]></category>
		<category><![CDATA[Functional Programming]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[Side Effects]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Virtual Machine]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/?p=626</guid>
		<description><![CDATA[And so continues one of the biggest constants in software development: the unerring sense among developers that the level of abstraction they&#8217;re current working at is exactly the right one for the task at hand. Anything lower-level is seen as barbaric, and anything higher-level is a bloated, slow waste of resources. This remains true even [...]]]></description>
			<content:encoded><![CDATA[<blockquote>
<p>And so continues one of the biggest constants in software development: <strong>the unerring sense among developers that the level of abstraction they&#8217;re current working at is exactly the right one</strong> for the task at hand.  Anything lower-level is seen as barbaric, and anything higher-level is a bloated, slow waste of resources.  This remains true <strong>even as the overall level of abstraction across the industry marches ever higher</strong>.</p>
<p>First the C guys can&#8217;t imagine writing in assembly anymore, but C++&#8217;s <a href="http://en.wikipedia.org/wiki/Virtual_method_table">vtable</a> dispatch is still just too slow to consider.  Then the C++ guys look back with chagrin at the bad-old-days of rolling their own half-assed object systems in C, but Java is dismissed as a ridiculous pig.  Still later, the Java guys sneer at pointers and manual memory management, but JavaScript is ridiculed as a <a href="http://nodejs.org/">toy &#8220;scripting&#8221; language</a> for validating web forms.  And on and on.</p>
<p>And in the short term, in the moment, they&#8217;re often right.  But this arrow points <a href="http://rentzsch.tumblr.com/post/641320178/a-simple-thought-experiment">only one way</a>, and that&#8217;s in the direction of ever-higher abstraction.  To judge how much time remains before the next leap forwards, look at the leading edge of the industry.</p>
</blockquote>
<p>&#8211;<a href="http://arstechnica.com/apple/news/2010/06/copland-2010-revisited.ars/2#intransigence">John Siracusa</a> (emphasis mine)</p>
<p>Here&#8217;s my two cents on the future of abstraction: systems are clearly getting wider (paralell), not faster; technologies like <a href="http://developer.apple.com/mac/library/documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html">Grand Central Dispatch</a> help us deal with  concurrency today, but longer term, I think a functional programming abstraction is the answer.</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2010/06/17/the-arrow-points-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thread Local Storage in Cocoa</title>
		<link>http://vgable.com/blog/2008/12/29/thread-local-storage-in-cocoa/</link>
		<comments>http://vgable.com/blog/2008/12/29/thread-local-storage-in-cocoa/#comments</comments>
		<pubDate>Mon, 29 Dec 2008 14:48:11 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sample Code]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[NSThread]]></category>
		<category><![CDATA[Threads]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/12/29/thread-local-storage-in-cocoa/</guid>
		<description><![CDATA[[[NSThread currentThread] threadDictionary] gives you an NSMutableDictionary that you can use for thread-specific storage.]]></description>
			<content:encoded><![CDATA[<p><code>[[NSThread currentThread] threadDictionary]</code> gives you an <code>NSMutableDictionary</code> that you can use for thread-specific storage.</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/12/29/thread-local-storage-in-cocoa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Always Update the View From the Main Thread</title>
		<link>http://vgable.com/blog/2008/12/26/always-update-the-view-from-the-main-thread/</link>
		<comments>http://vgable.com/blog/2008/12/26/always-update-the-view-from-the-main-thread/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 00:04:21 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Bug Bite]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Quotes]]></category>
		<category><![CDATA[AppKit]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[Threads]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/12/26/always-update-the-view-from-the-main-thread/</guid>
		<description><![CDATA[I wish I&#8217;d read this years ago: AppKit, the GUI framework, is not thread safe. In order for things to work properly, you (almost) always need to update GUI classes from the main thread &#8211;Dave Dribin (slightly edited) I&#8217;ve run into UI + threading problem before, but I&#8217;d just never seen this limitation of AppKit [...]]]></description>
			<content:encoded><![CDATA[<p>I wish I&#8217;d read this years ago:</p>
<blockquote><p> <strong>AppKit, the GUI framework, is not thread safe. In order for things to work properly, you (almost) always need to update GUI classes from the main thread</strong></p></blockquote>
<p>&#8211;<a href="http://www.dribin.org/dave/blog/archives/2008/05/22/invoke_on_main_thread/">Dave Dribin</a> (slightly edited)</p>
<p>I&#8217;ve <a href="http://vgable.com/blog/2008/05/14/nsalert-sheets-threads-inexplicable-bugs/">run into UI + threading problem before</a>, but I&#8217;d just never seen this limitation of AppKit spelled out.</p>
<p><a href="http://www.dribin.org/dave/blog/archives/2008/05/22/invoke_on_main_thread/">Dave&#8217;s article explains how to call code on the main thread</a> better then I can.</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/12/26/always-update-the-view-from-the-main-thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Multi</title>
		<link>http://vgable.com/blog/2008/12/22/how-to-multi/</link>
		<comments>http://vgable.com/blog/2008/12/22/how-to-multi/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 21:54:46 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Quotes]]></category>
		<category><![CDATA[Distributed Computing]]></category>
		<category><![CDATA[Futurism]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[Parallelization]]></category>
		<category><![CDATA[Threads]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/12/22/how-to-multi/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<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>
<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>
<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>
<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>
<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>
<p>&#8211;<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>
<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>
<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>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/12/22/how-to-multi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast Enough or Not Enough Fast?</title>
		<link>http://vgable.com/blog/2008/12/18/fast-enough-or-not-enough-fast/</link>
		<comments>http://vgable.com/blog/2008/12/18/fast-enough-or-not-enough-fast/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 00:11:31 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Quotes]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[Futurism]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[Optimization]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/12/18/fast-enough-or-not-enough-fast/</guid>
		<description><![CDATA[&#8230;people are now willing to make trade-offs against performance. For the entire history of the PC industry, computers have been too slow, so trade-offs were made in favor of faster CPUs: higher prices and heavier laptops. But today, for many common tasks, the type of CPU you get when you build a $400 lightweight laptop [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8230;people are now willing to make trade-offs <em>against</em> performance. For the entire history of the PC industry, computers have been too slow, so trade-offs were made in favor of faster CPUs: higher prices and heavier laptops. But today, for many common tasks, the type of CPU you get when you build a $400 lightweight laptop is fast enough. That’s (a) breakthrough.</p></blockquote>
<p>&#8211;<a href="http://daringfireball.net/linked/2008/12/18/netbookse">John Gruber</a></p>
<p>Cynically I also wonder if this is because &#8220;more cores&#8221; isn&#8217;t as compelling as <em>faster</em>.  As <a href="http://whydoeseverythingsuck.com/2008/06/false-hope-of-apples-snow-leopard.html">Hank Williams says</a>,</p>
<blockquote><p>The problem of multi-core computing is really very simple. As most of us have experienced, every problem *can’t* be solved better or faster with more people. Some problems can be solved faster by adding a few people, but most problems cannot. In truth, most problems can best, or only be solved by one person at a time. And so it is with computing. The vast majority of problems can only be solved by one logic thread at a time. The reason is obvious. For most process-oriented work, step B is based on the results of step A. And step C is based on the results of step B, and so on.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/12/18/fast-enough-or-not-enough-fast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSAlert + Sheets + Threads = Inexplicable Bugs</title>
		<link>http://vgable.com/blog/2008/05/14/nsalert-sheets-threads-inexplicable-bugs/</link>
		<comments>http://vgable.com/blog/2008/05/14/nsalert-sheets-threads-inexplicable-bugs/#comments</comments>
		<pubDate>Thu, 15 May 2008 03:08:02 +0000</pubDate>
		<dc:creator>Vincent Gable</dc:creator>
				<category><![CDATA[Bug Bite]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[NSAlert]]></category>
		<category><![CDATA[Threads]]></category>

		<guid isPermaLink="false">http://vgable.com/blog/2008/05/14/nsalert-sheets-threads-inexplicable-bugs/</guid>
		<description><![CDATA[UPDATED 2008-12-26: in general, all AppKit code should be called on the main thread. Problem: When using an NSAlert to display a sheet in a multi-threaded application, unexpected badness can happen. I was using beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo: To display an NSAlert as a sheet. But when the sheet appeared, the window it was attached to disappeared and [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATED 2008-12-26: <a href="http://vgable.com/blog/2008/12/26/always-update-the-view-from-the-main-thread/">in general, <em>all</em> AppKit code should be called on the main thread</a>.</p>
<p><strong>Problem:</strong><br />
When using an <code><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/index.html"><strong>NSAlert</strong></a></code> to display a <strong>sheet</strong> in a <strong>multi-threaded application</strong>, unexpected badness can happen.</p>
<p>I was using<br />
<a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/Reference/Reference.html#//apple_ref/occ/instm/NSAlert/beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:"><code>beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:</code></a><br />
To display an <code><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSAlert_Class/index.html">NSAlert</a></code> as a sheet.</p>
<p>But when the sheet appeared, the window it was attached to disappeared and got into some weird broken state where it would appear iff the application was not frontmost.</p>
<p>Fortunately, I remembered <a href="http://imlocation.wordpress.com/2007/10/11/nsalert-sheet-not-having-focus/">having encountered weirdness with <code>NSAlert</code> sheets before</a>.  The symptoms were different (previously the alert didn&#8217;t have focus), but the same solution still worked.</p>
<p><strong>Solution:</strong> make sure the message to display the sheet is sent by the main thread.  To do this, put the call to <code>beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:</code> inside another method, <code>showMyAlert</code>, then use <code>performSelectorOnMainThread:withObject:waitUntilDone:</code> to make sure <code>showMyAlert</code> is called on the main thread.</p>
<p><strong>Work around</strong> use <code>runModal</code> to display the alert as a modal dialog instead of a sheet.  <code>runModal</code> Does not appear to have any problems when called from other threads.</p>
<p><del>Just like <a href="http://imlocation.wordpress.com/2007/10/11/nsalert-sheet-not-having-focus/">last time</a>:</p>
<blockquote><p>The whole incident feels funny to me.  I suspect there may be some deeper issue at work that I am not aware of.  When I have time to investigate further I shall update this post.  Unfortunately I don&#8217;t have time to look into &#8216;solved&#8217; bugs today.</p></blockquote>
<p></del></p>
<p>UPDATED 2008-12-26: <a href="http://vgable.com/blog/2008/12/26/always-update-the-view-from-the-main-thread/">in general, <em>all</em> AppKit code should be called on the main thread</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://vgable.com/blog/2008/05/14/nsalert-sheets-threads-inexplicable-bugs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

