OS X 10.10

I have a highly CPU-bound project that parallelizes well. A small case has
about 5000 tasks that can execute concurrently (max is ~100,000). I would
like to use GCD queues to take advantage of the 24 cores I have on my
MacPro. Does GCD automatically limit the number of tasks that become
current on its queues to the number of cores (hw.logicalcpu)? Or is it the
programmer's responsibility to manage this?

Suppose I do something like this:

    dispatch_group_t workgroup = dispatch_group_create();

    dispatch_apply(4950,
                   dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,
0),
                   ^(size_t i) {

        dispatch_group_enter(workgroup);

        // Code block for executing task i . . .

        dispatch_group_leave(workgroup);

    });

    dispatch_group_wait(workgroup, DISPATCH_TIME_FOREVER);

    // Done with all 4950 tasks


Will this cause GCD to limit itself to 24 actively concurrent tasks until
all 4950 are done? Is there a better way to manage this?

-Carl


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to