<div dir="ltr">Thanks for the support.<div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 19, 2018 at 1:08 PM Brad Bell <<a href="mailto:bradbell@seanet.com">bradbell@seanet.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">One needs a separate copy of a tape for each thread.<br>
This is because there is information stored along with the operation sequence that is the tape.<br>
<br>
It is possible to make one tape recording, then make multiple copies of the tape using the <br>
assignment operator<br>
<a href="http://coin-or.github.io/CppAD/doc/funconstruct.htm#Assignment%20Operator" rel="noreferrer" target="_blank">http://coin-or.github.io/CppAD/doc/funconstruct.htm#Assignment%20Operator</a><br>
Then uses a separate copy for each thread.<br>
<br>
On 12/19/2018 12:11 PM, Perry de Valpine wrote:<br>
> Thanks for the quick reply.<br>
><br>
> I had already been through the documentation you pointed me to.<br>
><br>
> Did my question about recording tapes vs. using tapes make sense?  The examples seem to show each <br>
> thread both recording and using its own tape.  What I understand from the documentation is that <br>
> CppAD's multi-thread tools are necessary because internally some globals are used, so CppAD needs <br>
> to be told to manage separate copies of those globals for each thread.  My question was whether <br>
> that is the case just for recording tapes or also for using tapes, which might have been recorded <br>
> and copied in serial execution?  If my question doesn't make sense, I'd probably benefit from any <br>
> explanation you can offer.<br>
><br>
> Also can you help me understand the difference between the thread_num function that is passed to <br>
> thread_alloc::parallel_setup vs. thread_alloc::thread_num <br>
> (<a href="https://coin-or.github.io/CppAD/doc/ta_thread_num.htm" rel="noreferrer" target="_blank">https://coin-or.github.io/CppAD/doc/ta_thread_num.htm</a>)? Does the latter call the former?<br>
><br>
> Thanks again.<br>
><br>
> On Wed, Dec 19, 2018 at 10:08 AM Brad Bell <<a href="mailto:bradbell@seanet.com" target="_blank">bradbell@seanet.com</a> <mailto:<a href="mailto:bradbell@seanet.com" target="_blank">bradbell@seanet.com</a>>> wrote:<br>
><br>
>     Here is the link to the key CppAD requirements for multi-threading<br>
>     <a href="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=" rel="noreferrer" target="_blank">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=</a><br>
><br>
>     CppAD has to know a maximum number of threads, and which thread is currently running.<br>
>     It seems from<br>
>     <a href="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=" rel="noreferrer" target="_blank">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=</a><br>
>     that this is not possible in TBB, but I am not sure.<br>
><br>
>     On 12/19/2018 10:50 AM, Perry de Valpine wrote:<br>
>     > Hello.  I'm not sure if you prefer queries here or on GitHub.  This is a general question so<br>
>     I'm<br>
>     > sending it to this list.<br>
>     ><br>
>     > I'm trying to see whether CppAD's multi-threading features can fit well with Threading Building<br>
>     > Blocks (TBB).  Has anyone combined these successfully?  The simplest TBB example is here:<br>
>     ><br>
>     <a href="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=" rel="noreferrer" target="_blank">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=</a><br>
>     . Since TBB abstracts away thread creation but CppAD<br>
>     > seems to require explicit thread management, I'm not sure if they're a natural fit for each<br>
>     > other.  I can start to see how it might be done but wanted to ask for any suggestions first<br>
>     since<br>
>     > I am relatively new to multi-threading issues.<br>
>     ><br>
>     > What I would like to do is create a tape in serial mode and then in parallel use multiple<br>
>     copies<br>
>     > of that tape. The CppAD examples all show each thread both creating and using a tape.   Is<br>
>     what I<br>
>     > want to do possible?  I would also like to do this for multiple tapes (of different operations)<br>
>     > that all get created once and then used repeatedly in different places.<br>
>     ><br>
>     > Based on the statements on parallel_ad<br>
>     (<a href="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=" rel="noreferrer" target="_blank">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=</a>),<br>
><br>
>     > which are not totally clear to me (maybe because I lack the background), does one need to do<br>
>     the<br>
>     > parallel_setup and parallel_AD steps if multiple threads will be used only for running tapes<br>
>     > (ADFun objects) but not making new tapes?<br>
>     ><br>
>     > Thanks for the great software.<br>
>     ><br>
>     > Perry<br>
>     ><br>
>     ><br>
>     ><br>
>     > _______________________________________________<br>
>     > CppAD mailing list<br>
>     > <a href="mailto:CppAD@list.coin-or.org" target="_blank">CppAD@list.coin-or.org</a> <mailto:<a href="mailto:CppAD@list.coin-or.org" target="_blank">CppAD@list.coin-or.org</a>><br>
>     ><br>
>     <a href="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=" rel="noreferrer" target="_blank">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=</a><br>
><br>
>     _______________________________________________<br>
>     CppAD mailing list<br>
>     <a href="mailto:CppAD@list.coin-or.org" target="_blank">CppAD@list.coin-or.org</a> <mailto:<a href="mailto:CppAD@list.coin-or.org" target="_blank">CppAD@list.coin-or.org</a>><br>
>     <a href="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=" rel="noreferrer" target="_blank">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=</a><br>
><br>
<br>
</blockquote></div></div></div>