[CppAD] Multi-threading with TBB?
Brad Bell
bradbell at seanet.com
Wed Dec 19 15:57:25 EST 2018
thread_alloc::thread_num calls the function passed in thread_alloc::parallel_setup.
This is a link from the threading system to thread_alloc and the rest of CppAD.
On 12/19/2018 12:11 PM, Perry de Valpine wrote:
> Thanks for the quick reply.
>
> I had already been through the documentation you pointed me to.
>
> Did my question about recording tapes vs. using tapes make sense? The examples seem to show each
> thread both recording and using its own tape. What I understand from the documentation is that
> CppAD's multi-thread tools are necessary because internally some globals are used, so CppAD needs
> to be told to manage separate copies of those globals for each thread. My question was whether
> that is the case just for recording tapes or also for using tapes, which might have been recorded
> and copied in serial execution? If my question doesn't make sense, I'd probably benefit from any
> explanation you can offer.
>
> Also can you help me understand the difference between the thread_num function that is passed to
> thread_alloc::parallel_setup vs. thread_alloc::thread_num
> (https://coin-or.github.io/CppAD/doc/ta_thread_num.htm)? Does the latter call the former?
>
> Thanks again.
>
> On Wed, Dec 19, 2018 at 10:08 AM Brad Bell <bradbell at seanet.com <mailto:bradbell at seanet.com>> wrote:
>
> Here is the link to the key CppAD requirements for multi-threading
> https://urldefense.proofpoint.com/v2/url?u=https-3A__coin-2Dor.github.io_CppAD_doc_ta-5Fparallel-5Fsetup.htm&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=dGUSP0mcZ-4eFJdLgjemIUFvQwbOKo1wqmE_55NIGdc&m=Uc1__A27KLDN7APwoeTDVj5NwsKADcvMO9r-o1yZWS4&s=kFwgcVYei9YZYEdnnAJfV3EyhG0Ag7dl21aNJ4w-URc&e=
>
> CppAD has to know a maximum number of threads, and which thread is currently running.
> It seems from
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_3786408_number-2Dof-2Dthreads-2Dused-2Dby-2Dintel-2Dtbb&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=dGUSP0mcZ-4eFJdLgjemIUFvQwbOKo1wqmE_55NIGdc&m=Uc1__A27KLDN7APwoeTDVj5NwsKADcvMO9r-o1yZWS4&s=ACu19InrLSfMxKYSzdCAiytyoiclPYCkFxbTa2cJCdQ&e=
> that this is not possible in TBB, but I am not sure.
>
> On 12/19/2018 10:50 AM, Perry de Valpine wrote:
> > Hello. I'm not sure if you prefer queries here or on GitHub. This is a general question so
> I'm
> > sending it to this list.
> >
> > I'm trying to see whether CppAD's multi-threading features can fit well with Threading Building
> > Blocks (TBB). Has anyone combined these successfully? The simplest TBB example is here:
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__software.intel.com_en-2Dus_node_506057&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=dGUSP0mcZ-4eFJdLgjemIUFvQwbOKo1wqmE_55NIGdc&m=Uc1__A27KLDN7APwoeTDVj5NwsKADcvMO9r-o1yZWS4&s=U5kKsJw4CWu16GI3oMRqLsIQ2kOhjXSWiLsB0gobId8&e=
> . Since TBB abstracts away thread creation but CppAD
> > seems to require explicit thread management, I'm not sure if they're a natural fit for each
> > other. I can start to see how it might be done but wanted to ask for any suggestions first
> since
> > I am relatively new to multi-threading issues.
> >
> > What I would like to do is create a tape in serial mode and then in parallel use multiple
> copies
> > of that tape. The CppAD examples all show each thread both creating and using a tape. Is
> what I
> > want to do possible? I would also like to do this for multiple tapes (of different operations)
> > that all get created once and then used repeatedly in different places.
> >
> > Based on the statements on parallel_ad
> (https://urldefense.proofpoint.com/v2/url?u=https-3A__coin-2Dor.github.io_CppAD_doc_parallel-5Fad.htm&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=dGUSP0mcZ-4eFJdLgjemIUFvQwbOKo1wqmE_55NIGdc&m=Uc1__A27KLDN7APwoeTDVj5NwsKADcvMO9r-o1yZWS4&s=cxQ9bvZUkZ9p3DZ0g4O9ecRfplKTnAexABwQnXS2tpQ&e=),
>
> > which are not totally clear to me (maybe because I lack the background), does one need to do
> the
> > parallel_setup and parallel_AD steps if multiple threads will be used only for running tapes
> > (ADFun objects) but not making new tapes?
> >
> > Thanks for the great software.
> >
> > Perry
> >
> >
> >
> > _______________________________________________
> > CppAD mailing list
> > CppAD at list.coin-or.org <mailto:CppAD at list.coin-or.org>
> >
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cppad&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=dGUSP0mcZ-4eFJdLgjemIUFvQwbOKo1wqmE_55NIGdc&m=Uc1__A27KLDN7APwoeTDVj5NwsKADcvMO9r-o1yZWS4&s=t3fua1j4WWrTlEaRrF1uxB5fhl6ha4p8-fOBdGdKc8s&e=
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org <mailto:CppAD at list.coin-or.org>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cppad&d=DwIGaQ&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=dGUSP0mcZ-4eFJdLgjemIUFvQwbOKo1wqmE_55NIGdc&m=Uc1__A27KLDN7APwoeTDVj5NwsKADcvMO9r-o1yZWS4&s=t3fua1j4WWrTlEaRrF1uxB5fhl6ha4p8-fOBdGdKc8s&e=
>
More information about the CppAD
mailing list