On 13 January 2015 at 17:10, Robbie King (robking) <[email protected]> wrote:
> How about:
>
> /**
>  * Find next cpu in mask
>  *
>  * Finds the next cpu in the CPU mask, starting at the cpu passed.
>  * Use with odp_cpumask_first to traverse a CPU mask, i.e.
>  *
>  *   int cpu = odp_cpumask_first(&mask);
>  *   while (0 <= cpu) {
>  *       ...
>  *       ...
>  *       cpu = odp_cpumask_next(&mask, cpu);
>  *   }
>  *
>  * @param mask        CPU mask to find next cpu in
>  * @param cpu         CPU to start from
>  * @return cpu found else -1
>  */
+1

>
> -----Original Message-----
> From: Ola Liljedahl [mailto:[email protected]]
> Sent: Tuesday, January 13, 2015 10:58 AM
> To: Robbie King (robking)
> Cc: Savolainen, Petri (NSN - FI/Espoo); [email protected]
> Subject: Re: [lng-odp] [PATCHv2 1/2] Convert linux thread/proc helpers to use 
> core mask
>
> On 13 January 2015 at 16:35, Robbie King (robking) <[email protected]> wrote:
>> Yes, that’s a good point. A quick usage blurb would be useful.
> A little code snippet in the header file perhaps?
>
>>
>> -----Original Message-----
>> From: Savolainen, Petri (NSN - FI/Espoo) [mailto:[email protected]]
>> Sent: Tuesday, January 13, 2015 10:33 AM
>> To: Robbie King (robking); [email protected]
>> Subject: RE: [lng-odp] [PATCHv2 1/2] Convert linux thread/proc helpers to 
>> use core mask
>>
>> It makes sense. I managed to mix things up. Should we add documentation that 
>> "cpu" parameter is typically coming from odp_cpumask_first().
>>
>> -Petri
>>
>>> -----Original Message-----
>>> From: ext Robbie King (robking) [mailto:[email protected]]
>>> Sent: Tuesday, January 13, 2015 5:23 PM
>>> To: Savolainen, Petri (NSN - FI/Espoo); [email protected]
>>> Subject: RE: [lng-odp] [PATCHv2 1/2] Convert linux thread/proc helpers to
>>> use core mask
>>>
>>> Hey Petri, I think it needs to be there at least the way I am currently
>>> using it.  You begin the process by calling "odp_cpumask_first" to get
>>> your starting CPU, and the "next" function is the continuation.  So
>>> the CPU number passed into the function is assumed to be the previously
>>> set CPU, and we are searching for the next one.  So the "+1" is necessary
>>> to skip over the CPU passed in (else you would just keep finding the
>>> same CPU).
>>>
>>> If you wanted to only use "odp_cpumask_next", I think it could be
>>> done with passing in "-1" as the CPU to indicate start versus
>>> continuation.
>>>
>>> Hope this makes sense.
>>>
>>> > +int odp_cpumask_next(const odp_cpumask_t *mask, int cpu)
>>> > +{
>>> > +   for (cpu += 1; cpu < CPU_SETSIZE; cpu++)
>>>
>>>
>>> First valid cpu ID is 0. So, "cpu += 1" should not be there, right?
>>>
>>> -Petri
>>>
>>>
>>> > +           if (odp_cpumask_isset(mask, cpu))
>>> > +                   return cpu;
>>> > +   return -1;
>>> > +}
>> _______________________________________________
>> lng-odp mailing list
>> [email protected]
>> http://lists.linaro.org/mailman/listinfo/lng-odp

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to