Inside Mac OS X Snow Leopard: GPU Optimization

Posted:
in macOS edited January 2014
As jingle-pundits desperately try to denigrate Snow Leopard as a "Service Pack," Apple's new operating system reference release actually expands the reach of the Mac platform in several important and under-reported new directions. Here's the third in a series looking closer at some of Snow Leopard's well-known, but often misrepresented or misunderstood features.



OpenGL, OpenCL, and Grand Central Dispatch



Apple's support for OpenGL and its introduction of OpenCL as the new standard in GPGPU computing will work together to weaken Microsoft's proprietary push to make DirectX/D3D the primary API supported by GPU hardware developers such as AMD/ATI and NVIDIA.



As other platforms also throw their support exclusively behind OpenGL, from the Wii to the PlayStation 3 to Apple's own considerable iPhone/iPod touch juggernaut in mobile device computing, the market power Microsoft has established in its efforts to kill open GPU standards and substitute them with Windows-only substitutes will continue to fade.



The move toward greater utilization of available GPU resources, along with Snow Leopard's Grand Central Dispatch architecture which helps makes this easy and transparent for developers to deliver, also makes it possible to Apple to innovate in future hardware, adding new acceleration chips of its own design or simply including better support for the existing GPU resources available from today's vendors.



Where the GPU puck was headed



Just as in the move to 64-bits, Microsoft is splintered between trying to accommodate simple, low-power netbooks and the long tail of Windows XP users in its installed base with new, modern systems that actually use the same level of advanced graphics compositing that Apple premiered ten years ago.



According to the monthly hardware data report published by Valve's Steam covering roughly a million PC users, even among members of the gaming community, most of whom have 512MB or more of VRAM and a better GPU than most Mac users and, the majority are still running Windows XP, on operating system which offers no GPU-accelerated user interface. Similarly, only 17% of this high end gamer demographic is running a 64-bit edition of Windows, despite being a population that benefits the most from 64-bit addressing.



Apple not only grasped the power of the GPU in 1999 but applied it in Mac OS X's Quartz Graphics; Microsoft didn't get its own product with advanced, modern graphics compositing to market until Vista in 2007, and then failed to actually sell it to its users. Even among Valve's Steam users, who represent the premium fringe of early adopter, big spending PC buyers, only 36% are now running Vista, nearly three years after its launch.



On the other end, most low-end netbooks running Windows 7 will still be lacking the GPU support Apple managed to get into the iPhone in 2007, because most netbooks use the same architecture as low end generic PCs: an Intel CPU paired with chipset graphics. The iPhone uses an embedded "System on a Chip" which includes an ARM core along with with high performance, dedicated graphics cores that Apple has fully exploited to defer interface-related processing to hardware, much like a video game system.



Apple Bets on GPUs



As a corporate strategy expert from a leading mobile company wrote, "Apple was the first one to have this insight in desktop computing [?]. Windows was stuck in the old CPU driven architecture while OSX moved large parts of the code behind UI and rendering to those high power GPUs initially developed for gaming. It took 5 years or so from the mighty Microsoft to hammer its OS to adapt to this new computing paradigm and release Vista.



"And exactly the same happened in mobile devices. Apple's competitors were developing OS architectures initially built for menu driven UI's in the times when CPU was the main processing unit. Effective use of the GPU will play an increasingly large role as devices get more mobile and as users' expectations increase. Apple is ahead of the game both in conventional PCs and in mobile devices, with rivals such as Microsoft and Nokia just recently discovering the importance of focusing on the GPU to deliver the power needed to provide a rich, animated user interface.



"What Apple needed to do was to downscale its OSX a bit and partner with Imagination Technologies to develop a powerful mobile optimized graphics core. Suddenly they could run an UI that required several multiples of processing power the traditional mobile computing platforms were able to deliver. But since iPhone used GPU to crunch the heavy parts of UI code Apple could do it. The rest is history.



"There is a long list of other things Apple did right and assets they had, but without a great 'inertia' in mobile operating systems and this shift in mobile computing platforms they would have not been able to shake the market so greatly."



By sharing technology between its iPhone and Mac platforms, Apple is building upon its lead in fully exploiting the latent power available in the GPU. Snow Leopard specifically delivers a richer, subtly more animated user interface right out of the box and provides powerful toolkits to allow third party developers to wring the most performance from the hardware available.



Inside Mac OS X Snow Leopard: QuickTime X

Inside Mac OS X Snow Leopard: 64-bits

Inside Mac OS X Snow Leopard: Exchange Support

Inside Mac OS X Snow Leopard: Malware Protection







Daniel Eran Dilger is the author of "Snow Leopard Server (Developer Reference)," a new book from Wiley available now for pre-order at a special price from Amazon.
«13456

Comments

  • Reply 1 of 102
    stuffestuffe Posts: 391member
    There's not a lot of meat in this article, compared to the others in the series. I don;t care what Windows did in the past, or what Windows Gamers still use, I want to know about SL, and despite the strapline, this article only talks about openGL, not OCL or GCD.
  • Reply 2 of 102
    I wonder how much OpenCL helps in video playback especially on new MBPs with Nvidia 9400 M graphics. Has anyone tested how much one can reduce the CPU usage while watching videos on sites like CNN and Youtube? I am interested in knowing if the Adobe flash player eating of CPU is somehow reduced because of the OpenCL support in SL. Unfortunately I can't do this as my MB is not equipped with Nvidia GPU. If someone has noticed some improvement, please let me know
  • Reply 3 of 102
    I look forward to some benchmarks with Snow Leopard optimized software and hardware. Perhaps a chart could show what work was once done by the processor only vs. what's now done by the GPU. Then again the processor will be optimized and peaked out (ideally), so I don't really know how that would look different, besides the GPU's being used.



    Until I can see some performance data comparisons I have to be satisfied with just knowing its there I guess.



    I also hope that OpenCL support is eventually added to older video cards either by Apple or a third party driver writer. That said, I'd still need to see it do something useful first, and in chart form please.
  • Reply 4 of 102
    Quote:
    Originally Posted by holywarrior007 View Post


    I wonder how much OpenCL helps in video playback especially on new MBPs with Nvidia 9400 M graphics. Has anyone tested how much one can reduce the CPU usage while watching videos on sites like CNN and Youtube? I am interested in knowing if the Adobe flash player eating of CPU is somehow reduced because of the OpenCL support in SL. Unfortunately I can't do this as my MB is not equipped with Nvidia GPU. If someone has noticed some improvement, please let me know



    First of all let me say I don't really care about 9400M's performance. The GPU is weak and I believe Apple puts way too much attention on it. Yes it replaces a GPU that is several folds weaker but still if you want real computing power you would be looking at dedicated GPUs with dedicated high speed VRAM. Anyway here are answers to some of your questions. OpenCL does not make flash any faster since there isn't a single OpenCL instruction in Flash. I would even go so far as to say that GPU acceleration in the Mac version of Flash is only present in the configuration GUI but that's not what Adobe's been saying ... Anyway to me the CPU usage is more than a proof.

    With plugins such as ClickToFlash you can however see how much better things can be. I have a 2.4 GHz early 2008 MBP ( 8600gt 256mb ). The flash version of YouTube videos use about 50-60% of one of the cores and that's on a good day. At the same time the h.264 version (using the opengl version of QT ) uses about 15-16%. Not that I feel either one of them ( in any other way than fan noise ) but the lower CPU usage results in longer battery life.
  • Reply 5 of 102
    Thanks for your reply. I actually meant any GPU from Nvidia not just 9400M. If I understood correctly you do observe less CPU load with OpenGL version of QT. Btw what OpenGl version of QT? Itried click2flash and it is very good but unfortunately it doesn't work with CNN site. Do you recommend other plugin etc. to reduce the CPU usage while watching flash movies? Yeah flash really sucks the battery life.
  • Reply 6 of 102
    Quote:
    Originally Posted by AppleInsider View Post


    As other platforms also throw their support exclusively behind OpenGL, from the Wii to the PlayStation 3 to Apple's own considerable iPhone/iPod touch juggernaut in mobile device computing, the market power Microsoft has established in its efforts to kill open GPU standards and substitute them with Windows-only substitutes will continue to fade.



    Realistically, while the Wii and PS3 may offer OpenGL, I doubt many AAA games actually use it. If you want to really push the console and get best performance they are coding at a lower level using tools proprietary to the platform to avoid overhead. I believe in the PS3 it's called GCM.



    Quote:
    Originally Posted by AppleInsider View Post


    On the other end, most low-end netbooks running Windows 7 will still be lacking the GPU support Apple managed to get into the iPhone in 2007, because most netbooks use the same architecture as low end generic PCs: an Intel CPU paired with chipset graphics. The iPhone uses an embedded "System on a Chip" which includes an ARM core along with with high performance, dedicated graphics cores that Apple has fully exploited to defer interface-related processing to hardware, much like a video game system.



    Intel GMA 950 may be slow, compared to PowerVR solutions, they are still superior. For one thing, the PowerVR MBX in most iPhones and iPod Touchs only have hardware T&L and are basically DirectX 7 level, whereas the Intel GMA 950 does have hardware pixel shaders and software vertex shaders making DirectX 9 complaint. In terms of absolute performance, the best comparison is probably between netbooks with the Intel GMA 500, which is actually a PowerVRSGX 535, like that in the iPhone 3G S, and netbooks with the Intel GMA 950. It's partially due to drivers, but the GMA 950 still offers superior performance to the GMA 500 (PowerVR SGX) when running on desktop operating systems.



    The advantage to GPUs on the iPhone is the resolution is a lot smaller, making the power available per pixel comparatively larger. PowerVR GPUs do have the advantage in H.264 acceleration though, whereas the GMA 950 only accelerates MPEG2.



    Quote:
    Originally Posted by holywarrior007 View Post


    I wonder how much OpenCL helps in video playback especially on new MBPs with Nvidia 9400 M graphics. Has anyone tested how much one can reduce the CPU usage while watching videos on sites like CNN and Youtube? I am interested in knowing if the Adobe flash player eating of CPU is somehow reduced because of the OpenCL support in SL. Unfortunately I can't do this as my MB is not equipped with Nvidia GPU. If someone has noticed some improvement, please let me know



    I don't believe OpenCL is directly related to video playback at all. Hardware acceleration like H.264 is done by dedicated video decode processors in GPUs and is not related to OpenCL. H.264 acceleration hardware is available in GPUs as far back as the ATI X1000 and nVidia 7000 series and have long been supported in Windows. Apple is only now adopting H.264 acceleration and only officially support the 9400M. GPUs also have hardware acceleration capabilities for a lot more formats like MPEG2, DIVX, VC-1/WMV, which Apple does not take advantage of.



    And OpenCL doesn't miraculously speed everything up in a system, particularly third-party plug-ins like Flash. You have to rewrite your code in OpenCL before you see benefits. For Apple, I believe Core Image has been rewritten using OpenCL and I guess parts of QuickTime X. OpenCL is more useful for video encoding than decoding, although I suppose OpenCL could be used for video post-processing to clean up or alter video playback.
  • Reply 7 of 102
    hattighattig Posts: 830member
    "Apple not only grasped the power of the GPU in 1999 but applied it in Mac OS X's Quartz Graphics;"



    Well, wasn't Quartz on the GPU a Jaguar feature in 2002?



    And GPU usage only really got going when Expose was added in Panther in 2003.



    This article is poor, it's short, it doesn't go into any depth. It's almost as if the author's email to the editor got truncated, or if he had an hour to come up with some content. I understand the motivation is low after Ars did their excellent article, but in the past AppleInsider has done some really good article series and this one just seems rather shallow.
  • Reply 8 of 102
    shadowshadow Posts: 373member
    The OpenCL performance could be significant even for a middle range hardware. A friend of mine showed me sample code from the Snow Leopard developer tools. It was called N-body simulator or something and was producing an executable called Galaxies (as far as I remember).

    The sample code allowed to switch between different resources - CPU, CPU vector unit (both for one core and multiple cores), GPU and combined GPU + CPU.



    He was running the demo on an older MBP (2.4 or 2.5 GHz dual core) with the GPU he said is the lowest supported by OpenCL. I did not wrote the exact configuration but wrote down some of the results:



    CPU, single core - 0 GFlops (less than 0.5 I guess)

    CPU, vector unit 1 core - 9 GFlops

    CPU, vector unit 2 cores - 17-18 GFlops

    GPU only - 10 GFlops

    CPU + GPU - 12 GFlops



    There were 6 different N-body objects in the demo, this is for the first of them. Did not try the others. But this was not selected on purpose, it just happened to be the first one.



    Note that the highest performance was with CPU vector units. It turns the fans on pretty soon, however.



    The demo highlights one more important aspect of the OpenCL implementation: it has a processor-only fallback, so the code could potentially run on any hardware.



    Other notes from that guy:



    - the new unibody MacBook Pro with dual graphics can use both GPUs for OpenCL and have notably better performance

    - the demo on the old MBP delivered some 30 times performance boost over non-OpenCL code. On last year Mac Pro (no HW details) you could get 200 - 250 times performance improvement.

    BUT:

    - OpenCL is not good for everything, specific tasks only.



    Notes on Grand Central Dispatch (GCD):

    - used in a bunch of new APIs on different levels ( C, objective-C )

    - could be used for almost anything - searching and/or replacing text, data processing, repetitive operations (loops), sorting etc. He observed that GCD-enabled APIs deliver performance boost even when executed synchronously (Probably because GSD operates on system level, as opposed to application/process level, or just because the underlying implementations were optimized).



    Let's wait and see what we will get in a couple of years.

    Unfortunately, fat ugly guys like Microsoft and Adobe will not do anything to take advantage of those technologies. Microsoft - for obvious reasons (they don't want their own software to run few times faster on Mac OS compared to Windows), and Adobe - because they want to have code that is supported by both Mac OS and Windows, so they are targeting the lowest denominator. As their release cycle shows, they are very reluctant to re-work their 20+ years old code base, so those code will die with them, hopefully soon enough.



    I hope Apple will show what OpenCL and GCD can do for the Pro software (Aperture, FCP) sooner than later.
  • Reply 9 of 102
    Quote:
    Originally Posted by ltcommander.data View Post


    And OpenCL doesn't miraculously speed everything up in a system, particularly third-party plug-ins like Flash. You have to rewrite your code in OpenCL before you see benefits. For Apple, I believe Core Image has been rewritten using OpenCL and I guess parts of QuickTime X. OpenCL is more useful for video encoding than decoding, although I suppose OpenCL could be used for video post-processing to clean up or alter video playback.



    Do you mean that OpenCL doesn't allow GPU to offload some of the task for playing flash movies on the web? I mean I read somewhere Apple touting that Nvidia GPU will help CPU in video playback, resulting in the less usage of CPU. Flash player takes too much CPU resources. I was expecting with OpenCL flash won't eat CPU too much.
  • Reply 10 of 102
    Quote:
    Originally Posted by holywarrior007 View Post


    Do you mean that OpenCL doesn't allow GPU to offload some of the task for playing flash movies on the web? I mean I read somewhere Apple touting that Nvidia GPU will help CPU in video playback, resulting in the less usage of CPU. Flash player takes too much CPU resources. I was expecting with OpenCL flash won't eat CPU too much.



    I'm pretty sure H.264 acceleration support is limited to QuickTime. I don't know if Apple made it available to third-parties that don't use QuickTime. Presumably, Adobe could write all their video decode code in OpenCL to make an OpenCL Flash plug-in, but that seems unlikely. The more likely solution is just for Adobe to better optimize their Flash code in OS X or make it multithreaded. Flash runs significantly better on Windows even on single core CPUs so there's a lot more room for improvement even without doing something more fancy and using OpenCL or even Grand Central.
  • Reply 11 of 102
    hattighattig Posts: 830member
    Quote:
    Originally Posted by holywarrior007 View Post


    Do you mean that OpenCL doesn't allow GPU to offload some of the task for playing flash movies on the web? I mean I read somewhere Apple touting that Nvidia GPU will help CPU in video playback, resulting in the less usage of CPU. Flash player takes too much CPU resources. I was expecting with OpenCL flash won't eat CPU too much.



    You could write OpenCL video decoders, but why do that when GPUs incorporate hardware video decoders that will use even less power?



    Now transcoding is another thing entirely. Here you could have an OpenCL encoder running on the GPU, accepting decoded video from the hardware decoder on the GPU.
  • Reply 12 of 102
    kotatsukotatsu Posts: 1,010member
    "As jingle-pundits desperately try to denigrate Snow Leopard as a "Service Pack"



    You mean people like Leo Laporte? The fanboy fueled writing on Apple Insider can be a bit much.
  • Reply 13 of 102
    panupanu Posts: 135member
    Steve Ballmer said that Windows 7 is Vista done right. So if Snow Leopard is a service pack, then Windows 7 is an apology. And you have to pay for that?
  • Reply 14 of 102
    Quote:
    Originally Posted by Panu View Post


    Steve Ballmer said that Windows 7 is Vista done right. So if Snow Leopard is a service pack, then Windows 7 is an apology. And you have to pay for that?



    Ballmer actually admitted publicly that:



    "Windows 7 is Windows Vista with cleanup in user interface [and] improvements in performance."



    http://www.computerworld.com/s/artic..._a_lot_better_



    And you got it right, Windows 7 is indeed an apology. Windows users haven't had a decent OS since 2001, and XP was really nothing to be proud of - an ugly, virus-ridden mess. And Windows sufferers expect people to be impressed??



    http://arstechnica.com/apple/reviews...-os-x-10-6.ars



    Some service pack.



    In any case, it nakes no difference, really. We're talking Macs and OS X here. Plenty to be happy about.
  • Reply 15 of 102
    A lot of claims in this article seem rather strange and shallow. None of this really means anything to the average consumer. Any PC user in need of a GPU will obviously not be running Intel GMA and those who have netbooks don't have need of a dedicated graphics card. Netbook users should really be using linux anyway if they want optimal performance while not sacrificing a whole lot in features since the purpose of a netbook is rather limited anyway. So the stab at Microsoft in the netbook market is kind of pointless.



    Apple should focus less on this sort of non sense and actually sell their products for that they're worth: a whole shibang less. I guarantee you a whole lot more people will switch if it costs them less money. Sure Windows 7 costs you money to upgrade (by the way, I haven't ever paid for an OS and I haven't bootlegged one either), but OS X costs you the premium of buying a new Mac over a new PC which is considerably higher. This is also partly the reason vista isn't widely adopted regardless of how good / bad it is. It still requires people to either upgrade or buy new hardware. XP's adoption rate was similarly low when it first came out.



    To a lay reader, it's almost like the article is trying to say that PC's didn't have graphics capabilities until 2007 while Macs have been processing high end graphics since 1999 and an iPhone is more powerful than a netbook. Think about that for a second. Way to go.



    Good luck trying to topple directx with OpenCL. I'll be picking up a GTX 300 happily awaiting DX11 and its integrated environment in Windows 7.



    Also, just to point out for the steam survey: 36% of steam users use Vista while 18% of the general population use vista. Food for thought.
  • Reply 16 of 102
    jeffdmjeffdm Posts: 12,946member
    Is there no chance that the abstract for this entire series of articles will be anything other than a copy and paste from the previous abstracts?



    Quote:
    Originally Posted by elliots11 View Post


    I also hope that OpenCL support is eventually added to older video cards either by Apple or a third party driver writer. That said, I'd still need to see it do something useful first, and in chart form please.



    Doesn't that depend on whether the chip architecture can sufficiently support what the standard needs?
  • Reply 17 of 102
    backtomacbacktomac Posts: 4,579member
    Quote:
    Originally Posted by cg0def View Post


    First of all let me say I don't really care about 9400M's performance. .



    Check this link out where users are benching open cl performance.



    Even the lowly 9400m has staggeringly good performance under open cl. It is significantly faster than the 2.0 Xenon Quad Mac pros from a few years back (Mac pro with two dual core Xenon cpus). I'm stunned at the potential open cl has. I hope Apple and developers get on the ball and get the apps that can leverage open cl coded to take advantage of it.



    Sure, the better video cards will offer even greater performance. But a mini with the 9400m may be able to best 1st gen Mac Pros using open cl. That's pretty impressive in my books. If I had a first gen MP i'd be looking for an open cl card to put in that machine.



    PS. Shadow's post is on the money.
  • Reply 18 of 102
    what the fuck is a jingle pundit
  • Reply 19 of 102
    cameronjcameronj Posts: 2,357member
    Quote:
    Originally Posted by Poppleganger View Post


    what the fuck is a jingle pundit



    It's what biased writers say to reveal their bias.
  • Reply 20 of 102
    Ah AH AH!!!! Talking about "Service pack" the only connection in my mind is with Wingarbage!!

    Apple and Mac OSX is future..Microsoft and Wingarbage is past.

Sign In or Register to comment.