• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Does GCD auto-limit concurrent tasks to number of cores?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Does GCD auto-limit concurrent tasks to number of cores?


  • Subject: Re: Does GCD auto-limit concurrent tasks to number of cores?
  • From: Carl Hoefs <email@hidden>
  • Date: Thu, 09 Apr 2015 12:26:49 -0700
  • Importance: Normal

Wonderful! Thank you for clearing this up for me!
-Carl

>
>> On Apr 9, 2015, at 12:07, Carl Hoefs <email@hidden>
>> wrote:
>>
>> 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)?
>
> Yes.
>
>> 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);
>>
>
> Note that your use of a dispatch_group here is redundant; dispatch_apply
> always executes synchronously with respect to the caller (i.e. when the
> above dispatch_apply has returned, all 4950 executions of your block have
> already completed).
>
>
> --
> Clark Smith Cox III
> email@hidden
>
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Does GCD auto-limit concurrent tasks to number of cores?
      • From: Mike Abdullah <email@hidden>
References: 
 >Does GCD auto-limit concurrent tasks to number of cores? (From: Carl Hoefs <email@hidden>)
 >Re: Does GCD auto-limit concurrent tasks to number of cores? (From: Clark Smith Cox III <email@hidden>)

  • Prev by Date: Re: Does GCD auto-limit concurrent tasks to number of cores?
  • Next by Date: Re: Does GCD auto-limit concurrent tasks to number of cores?
  • Previous by thread: Re: Does GCD auto-limit concurrent tasks to number of cores?
  • Next by thread: Re: Does GCD auto-limit concurrent tasks to number of cores?
  • Index(es):
    • Date
    • Thread