Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 20, 2009, 05:19 PM   #1
mobilehaathi
macrumors 68030
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: Bay Area, CA
OpenCL + multiple video cards

So I am considering a Mac Pro to help me along with some giant number crunching problems I'm working on, and I am curious about OpenCL with respect to multiple video cards. From my limited and simplified understanding at the moment, OpenCL allows you to send blocks of code out for parallel execution to open cores, including open cores on video cards. I assume this holds when having, say, four GT 120's. I'm thinking I could queue a bunch of blocks for parallel execution and have all four video cards (and maybe some i7 cores) cranking away. Does anyone know if this is an accurate (albeit very simplified) characterization?
__________________
Of crimes---none is greater than having things that one desires;
Of disasters---none is greater than not knowing when one has enough.
Of defects---none brings more sorrow than the desire to attain.

Last edited by mobilehaathi; Sep 20, 2009 at 06:06 PM. Reason: Changed "Grand Central" -> "OpenCL"
mobilehaathi is offline   0 Reply With Quote
Old Sep 20, 2009, 05:30 PM   #2
gnasher729
macrumors G4
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by mobilehaathi View Post
So I am considering a Mac Pro to help me along with some giant number crunching problems I'm working on, and I am curious about Grand Central Dispatch with respect to multiple video cards. From my limited and simplified understanding at the moment, GCD allows you to send blocks of code out for parallel execution to open cores, including open cores on video cards. I assume this holds when having, say, four GT 120's. I'm thinking I could queue a bunch of blocks for parallel execution and have all four video cards (and maybe some i7 cores) cranking away. Does anyone know if this is an accurate (albeit very simplified) characterization?
Grand Central Dispatch does no such thing. You are thinking about OpenCL here. And OpenCL will do what you are saying. I am not sure if OpenCL will send the same work to _different_ kinds of processors; you would have to read a bit more about their documentation.
gnasher729 is online now   0 Reply With Quote
Old Sep 20, 2009, 06:04 PM   #3
mobilehaathi
Thread Starter
macrumors 68030
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: Bay Area, CA
I guess I'm mixing up names. GCD is the scheduler, and OpenCL is the API? At any rate, I'm definitely going to be digging through the documentation soon. Thanks for the input.
__________________
Of crimes---none is greater than having things that one desires;
Of disasters---none is greater than not knowing when one has enough.
Of defects---none brings more sorrow than the desire to attain.
mobilehaathi is offline   0 Reply With Quote
Old Sep 21, 2009, 09:00 AM   #4
ManiG
macrumors member
 
Join Date: Aug 2009
GCD/OpenCL noob here, but I assume that dispatching blocks would be a good way to start OpenCL jobs in parallel to different OpenCL devices. They are different technologies, but are not mutually exclusive. Please correct me if I'm mistaken.

One interesting tidbit I picked up in Apple's OpenCL programming guide -- Apple's OpenCL CPU implementation takes advantage of GCD.
ManiG is offline   0 Reply With Quote
Old Sep 21, 2009, 11:34 AM   #5
gnasher729
macrumors G4
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by mobilehaathi View Post
I guess I'm mixing up names. GCD is the scheduler, and OpenCL is the API? At any rate, I'm definitely going to be digging through the documentation soon. Thanks for the input.
They are quite independent technologies really. GCD is a technology that makes it quite easy to run any normal CPU code on different threads. Just the same things that you could have done in any Posix system for many years, except that it is much easier to do, has much less overhead, and is balanced over the whole system, not just your application. To a large extent GCD is useful to make the user interface more responsive by doing things in the background instead of waiting for them.

With OpenCL, you need tasks that are massively parallel (like in graphics applications, where you have 1920 x 1200 pixels that need to be calculated independently of each other), and OpenCL then compiles these tasks to optimal code for GPUs and possibly CPUs and distributes them among those resources. To the caller, it doesn't seems as if there are any threads involved. OpenCL only works well with problems that are suitable to be handled that way, any dependencies between tasks make life very hard for OpenCL.
gnasher729 is online now   0 Reply With Quote
Old Sep 21, 2009, 12:59 PM   #6
Krevnik
macrumors 68020
 
Krevnik's Avatar
 
Join Date: Sep 2003
There are a couple sample apps for OpenCL on Apple's developer site that show what you can do.

How you spread the love around seems to be up to the developer, so you can use the devices available as you see fit. ManiG is right that GCD is probably ideal for kicking off and then concatenating OpenCL jobs when you want to spread calculation across multiple devices.

One thing that the NBody example tells me beyond the simple fact that they should have also used GCD... is that you will need some way to optimize the block size given to each device. Each device will have vastly different performance, especially based on the user's current setup. If you just split everything up equally, your total performance will actually fall down to the slowest device.

If your CPU cores can pull 12Gflops, your 8600M pulls 30Gflops, and the 8400M pulls 12Gflops as well... then you need to include a little time tracking. Ideally, all devices should be reporting in at the same time, and you will need to splice up the data blocks accordingly. So you'd feed about 55% to the 8600M, and 22.5% each to the CPUs and 8400M. You'd want to track this every run and adjust these percentages accordingly. It isn't too hard just using localtime() or similar to measure how long the OpenCL kernel took to execute, and report that back to your code that manages which device gets what block of data.
__________________
Mac Pro (2008), 13" rMBP, iPad 4 LTE, iPhone 5
Krevnik is offline   0 Reply With Quote
Old Sep 21, 2009, 02:09 PM   #7
mobilehaathi
Thread Starter
macrumors 68030
 
mobilehaathi's Avatar
 
Join Date: Aug 2008
Location: Bay Area, CA
Well, this is all sounding quite encouraging. Thankfully, my problems are embarrassingly parallel, and therefore seem well suited for this implementation. It seems a close reading of the documentation plus messing around on the lappy is indicated.

__________________
Of crimes---none is greater than having things that one desires;
Of disasters---none is greater than not knowing when one has enough.
Of defects---none brings more sorrow than the desire to attain.
mobilehaathi is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Best video card upgrade for PCI-E G5? ozziesironman PowerPC Macs 16 Aug 1, 2011 09:02 AM
Replacing MacPro Video Card RogersDA Mac Pro 15 Apr 11, 2011 07:15 PM
Video Card For Streaming turbobass Digital Video 6 Mar 5, 2011 07:46 PM
macbook pro late 2009, possible video card fail? samir684 MacBook Pro 1 Jan 25, 2011 05:02 PM


All times are GMT -5. The time now is 01:12 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC