Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

JPamplin

macrumors 6502
Original poster
Mar 12, 2009
321
64
Nashville, TN
Hi,

I'm running 10A432 of SL and I'd love to be able to test out any apps that have been recompiled for 10.6, to utilize Grand Central Dispatch and/or OpenCL. Developers have had the Preview for a while, but I have no idea if they have the version of XCode that supports it.

Is the version of XCode on the 432 DVD the correct one?

Does anyone know of any GCD/OpenCL demos, other than the apps in SL itself?

Perhaps this question is being posed too early, but you'd think there'd be something.

Thanks, JP
 
Hi,

I'm running 10A432 of SL and I'd love to be able to test out any apps that have been recompiled for 10.6, to utilize Grand Central Dispatch and/or OpenCL. Developers have had the Preview for a while, but I have no idea if they have the version of XCode that supports it.

Recompiled? I think you mean re-written.

I'm sure all the developers will get Right On That, just as soon as they have figured out multi-threading and are able to utilize more than two cores. (The 2nd core being used to keep a clock up to date, yeehaw!)

Perhaps this question is being posed too early, but you'd think there'd be something.
I think Steve has got a keynote you can watch.
 
Thanks for those comments. I thought the whole concept of Grand Central was to enable "nice" multi-threading without having to figure out how to do it the old way. Bertrand said they are merely extensions to existing C commands. But I agree that some re-writing may be necessary (I just hope it's not the whole thing).

Since 10.6 is near RTM I would have thought that :

a) OpenCL demos would have been produced by SOMEBODY to test what they are releasing,

b) they would have OpenCL drivers for nVidia and ATI by now (the ATI drivers are lagging in build 432 in benchmarks vs. 10.5.8), and

c) developers would have had code examples and documentation for a while now to at least try this stuff out...

So I don't think it's out of the question to see if anything's out there yet.

JP
 
I think it is out of the question seeing as I don't think Dev's would release programs to the public when the product its being released for isn't even out yet. (And I mean the final product, not just the build that could or couldnt not be GM)
 
Thanks for those comments. I thought the whole concept of Grand Central was to enable "nice" multi-threading without having to figure out how to do it the old way. Bertrand said they are merely extensions to existing C commands. But I agree that some re-writing may be necessary (I just hope it's not the whole thing).
Any one who knows says that multi-threading is HARD. Parallel is HARD. Those who know say those who disagree don't know what they are talking about. Those how know believe the only way to truly move forward in a parallel universe is to junk our current languages (C, Java,etc) and adopt entirely new languages that are were designed to facilitate parallelism.

a) OpenCL demos would have been produced by SOMEBODY to test what they are releasing,
There probably are some that will appear once 10.6 is on shelves.

b) they would have OpenCL drivers for nVidia and ATI by now (the ATI drivers are lagging in build 432 in benchmarks vs. 10.5.8), and
Leopard shipped with crap drivers too. The lesson is don't buy 10.6.0.. wait until 10.6.4.

c) developers would have had code examples and documentation for a while now to at least try this stuff out...

So I don't think it's out of the question to see if anything's out there yet.
Certainly. But expecting much commercial adoption is a different story. I can't believe Toast still doesn't use multi-threading. It's only been 10 years!
 
1Password has a 3.0 beta out for SL. It is a closed beta tho.

So... how much faster is it?

I hear TextEdit is 30% faster in 64-bit, and is able to peg all 8 cores on a Mac Pro when you do a polymorphic search & replace.
 
OpenCL Demos

There are a few OpenCL demos that you can download and try such as Galaxies, GJulia and Grass. You can get them from here:
http://www.insanelymac.com/forum/index.php?showtopic=183237

You can also see an OpenCL demo using REAL WORLD code from the scientific community at Macresearch.org. The demo starts near the end at about the 33 minute mark. VERY impressive !!!
http://www.macresearch.org/opencl_episode1

As for apps that use GCD/OpenCL... I only know of Acorn 2.0. It uses GCD but not OpenCL. I would expect that "most" apps, especially if they are CPU bound, will have incorporated GCD and/or OpenCL in a couple months (or less). I would hope that open source libraries would also be updated as MANY apps would benefit all at once!! (such as the FFMPEG libraries)

TheJ
 
Any one who knows says that multi-threading is HARD. Parallel is HARD. Those who know say those who disagree don't know what they are talking about. Those how know believe the only way to truly move forward in a parallel universe is to junk our current languages (C, Java,etc) and adopt entirely new languages that are were designed to facilitate parallelism.

There probably are some that will appear once 10.6 is on shelves.

Leopard shipped with crap drivers too. The lesson is don't buy 10.6.0.. wait until 10.6.4.

Certainly. But expecting much commercial adoption is a different story. I can't believe Toast still doesn't use multi-threading. It's only been 10 years!

yes multithreading in the traditional sense is very hard. However that is the point of GCD. It introduces a ready built api for multi threading. It requires only about 6 lines of code for the dev.
 
yes multithreading in the traditional sense is very hard. However that is the point of GCD. It introduces a ready built api for multi threading. It requires only about 6 lines of code for the dev.

It may only require 6 lines of code to create/dispatch however it most likely requires refactoring the guts of an application responsible for its main work. This is because while many apps are threaded already, the work each thread performs is not broken up into small enough pieces so as to benefit from the availability of ever-increasing number of CPU cores.

A simple example would be an intra-frame video encoder. Today a single-threaded design might run a thread to encode all 86400 frames of a 1-hour video at 24fps, one by one in sequence. Tomorrow, a multi-threaded design might probe the OS for number of CPUs (ncpu) and then manually divide the total number of frames by ncpu and launch ncpu*thread to process each chunk.

The GCD way might be to create 86400 blocks, each of which encodes exactly 1 frame and dispatch those blocks. The OS then takes care of processing the queue. Other issues like I/O streaming are purposely left out of this example, but I hope you all realize it's not simply 6-lines to convert an existing application to use GCD.
 
Having recently rewritten a ~350 line (i.e. rather simple) class to use GCD heavily, it's safe to say that while it's very nice, it's definitely not trivial. The class is now about 450 lines and most of those are different than the previous version; it also took a week or so of debugging various issues including writing a stress test that just hammered on it from 1000 threads at once until something went wrong.

GCD is very efficient, useful, and removes a lot of the boilerplate of queue-based concurrency and asynchronicity, but it doesn't magically make concurrent programming easy.

Although it's not at all intuitive from looking at it, GCD encourages two different patterns (that I'm aware of so far). One is the actor model, any mutable shared state in the program should be associated with a queue (actor) and interacted with only by passing blocks (messages... the similarity breaks down here a bit; they're more like continuations in this use) to that queue. The other is the more standard data parallel model.

For example, the standard synchronous accessor pattern:
Code:
- (NSArray *) thingies {
    return [thingies copy]; //avoid returning mutable internal state directly; I'm assuming garbage collection, so this isn't a leak
}
turns into something like (pardon my naming):
Code:
- (void) snapshotSharedThingiesThen:(void ^(NSArray *))continuation {
   dispatch_async(fooQueue, ^ {
        NSArray *snapshot = [thingies copy];
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ { 
             continuation(snapshot) 
        });
   });
}
and the code using it goes from:
Code:
for (id thingy in [something thingies]) {
    /* do some horrendously slow operation with each thingy that the rest of the program doesn't really care about*/
    [thingy doWork];
}
to:
Code:
[something snapshotSharedThingiesThen:^(NSArray *thingies) {
    //-enumerateObjectsWithOptions:usingBlock: is a fairly thin layer on top of dispatch_apply()
    [thingies enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:void (^)(id obj, NSUInteger idx, BOOL *stop) {
         /* do some horrendously slow operation with each thingy that the rest of the program doesn't really care about*/
         [obj doWork]; //note that -doWork must be threadsafe
    }];
}];

We've gone from synchronous and serial to asynchronous and parallel, but at the cost of totally restructuring how the code worked. In order to get results back to the UI we would "message" it using dispatch_async to the main queue (via dispatch_get_main_queue()), or if absolutely necessary, block using dispatch_semaphore, dispatch_sync, or dispatch_groups.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.