Boost logo

Boost Users :

Subject: Re: [Boost-users] Create A Boost Thread for each HW Thread?
From: Brian Budge (brian.budge_at_[hidden])
Date: 2011-06-10 10:50:46


On Thu, Jun 9, 2011 at 11:21 PM, Christoph Heindl
<christoph.heindl_at_[hidden]> wrote:
> On Fri, Jun 10, 2011 at 3:13 AM, Brad <boost_at_[hidden]> wrote:
>> What's the proper way to start a boost thread for each hardware thread
>> available? I can do this... but it is clunky and does not scale
>> (especially when there are lots of cores):
>>
>> const unsigned int hwt()
>> {
>>          const unsigned int t = boost::thread::hardware_concurrency();
>>          return t;
>> }
>
> try boost::thread_group [1]
>
> boost::thread_group tg;
>
> for (int i  =0; i < hwt(); ++i) {
>  tg.create_thread(...);
> }
> tg.join_all();
>
> Best regards,
> Christoph
>
> [1] http://www.boost.org/doc/libs/1_42_0/doc/html/thread/thread_management.html#thread.thread_management.threadgroup
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

I'm not sure if this was also part of the question, but even if not,
I'm also curious: Is there a boost-ey way of setting the affinity so
that the threads are pinned to physical cores?

I have my own wrappers at the moment, but I'd love to use something
from boost, if available.

Thanks,
  Brian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net