<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1666278949;
        mso-list-type:hybrid;
        mso-list-template-ids:74111212 67698703 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Greetings and Salutations,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I would suggest the following modifications:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><br>
1. Use the Rcpp omp plugin<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">// [[Rcpp::plugins(openmp)]<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Instead of using set flags. (assuming you are on Rcpp >= 0.10.5 )<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><br>
2. Modify the function parameters to include: int cores <br>
<br>
This allows you to specify cores during run time vs. compile time.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">3. Specify pragma directive such that it is:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">#pragma omp parallel for num_threads(cores)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Or use:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">omp_set_num_threads(cores);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><br>
The first is a more graceful fail if the system does not support openmp and overrides all set core values.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Regarding your questions:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span style="mso-list:Ignore">1.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">OpenMP will open up the requested number of threads. If you have a Parallel BLAS it will open up more OpenMP threads. This is problematic.
<br>
Consider:<br>
A machine with 8 cores.<br>
Default to using 4 cores to number of threads for the OpenMP problem.<br>
Assume that the Parallel BLAS is using 2 cores…<br>
Then, 4*2 = 8 cores are allocated for parallelization.<br>
<br>
So, depending on your allocation, you probably will have “step over.”<br>
<br>
<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo2"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><span style="mso-list:Ignore">2.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Reductions in OpenMP are generally only possible if you have: var  = var  op  expr (e.g. sum += x(i); )<br>
<br>
var is a scalar (e.g. sum, the summed value)<br>
op is the operator to apply (e.g. +, plus)<br>
expr is a scalar that does not reference var (e.g. x(i), new value) <br>
<br>
I’m confused as to whether you are referring to your final output e.g.    Y.row(i) = yu.t(); as the reduction.
<br>
<br>
If this is the case, the object, Y, is being updated in shared memory. Since only one row is updated, this is fine.
<br>
<br>
Everything else within the for loop is considered as private to the instance since it is declared within the pragma.
<br>
<br>
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">With your journey into OpenMP, these might help:<br>
<br>
Slides regarding OpenMP and RcppArmadillo:<br>
<a href="http://www.thecoatlessprofessor.com/wp-content/uploads/2014/09/hpc_parallel.pdf">http://www.thecoatlessprofessor.com/wp-content/uploads/2014/09/hpc_parallel.pdf</a>
<br>
<br>
Demo code for using OpenMP with Armadillo & Eigen using the tapering idea in spatial statistics:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><a href="https://github.com/coatless/pims_bigdata">https://github.com/coatless/pims_bigdata</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Sincerely,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><br>
JJB<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> rcpp-devel-bounces@lists.r-forge.r-project.org [mailto:rcpp-devel-bounces@lists.r-forge.r-project.org]
<b>On Behalf Of </b>Saurabh B<br>
<b>Sent:</b> Tuesday, May 26, 2015 4:53 PM<br>
<b>To:</b> rcpp-devel@lists.r-forge.r-project.org<br>
<b>Subject:</b> [Rcpp-devel] OpenMP and Parallel BLAS<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi there,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I am using gradient descent to reduce a large matrix of users and items. For this I am trying to use all 40 available cores but unfortunately my performance is no better than when I was using just one. I am new to openMP and RcppArmadillo
 so pardon my ignorance.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The main loop is -<o:p></o:p></p>
</div>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" style="border-collapse:collapse;border-spacing:0px">
<tbody>
<tr>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC27">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">#</span><span style="font-size:9.0pt;font-family:Consolas;color:#A71D5D">pragma</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">
 omp parallel for<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L28">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC28">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333"> 
</span><span style="font-size:9.0pt;font-family:Consolas;color:#A71D5D">for</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333"> (</span><span style="font-size:9.0pt;font-family:Consolas;color:#A71D5D">int</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">
 u = </span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">0</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">; u < C.n_rows; u++) {<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L29">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC29">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">    arma::mat Cu =
</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">diagmat</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">(C.</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">row</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">(u));<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L30">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC30">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">    arma::mat YTCuIY = Y.</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">t</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">()
 * (Cu) * Y;<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L31">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC31">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">    arma::mat YTCupu = Y.</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">t</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">()
 * (Cu + fact_eye) * P.</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">row</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">(u).</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">t</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">();<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L32">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC32">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">    arma::mat WuT = YTY + YTCuIY + lambda_eye;<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L33">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC33">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">    arma::mat xu =
</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">solve</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">(WuT, YTCupu);<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L34">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC34">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333"><o:p> </o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L35">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC35">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">   
</span><span style="font-size:9.0pt;font-family:Consolas;color:#969896">// Update gradient -- maybe a slow operation in parallel?</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333"><o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L36">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC36">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">    X.</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">row</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">(u)
 = xu.</span><span style="font-size:9.0pt;font-family:Consolas;color:#0086B3">t</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">();<o:p></o:p></span></p>
</td>
</tr>
<tr>
<td width="50" nowrap="" valign="top" style="width:37.8pt;border:solid #EEEEEE 1.0pt;border-top:none;padding:0in 7.5pt 0in 7.5pt;min-width:50px;color:rgba(0,0,0,0.298039)" id="L37">
</td>
<td valign="top" style="padding:0in 7.5pt 0in 7.5pt;word-wrap:normal;overflow:visible" id="LC37">
<p class="MsoNormal" style="line-height:10.9pt"><span style="font-size:9.0pt;font-family:Consolas;color:#333333">  }<o:p></o:p></span></p>
</td>
</tr>
</tbody>
</table>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">full code - <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_sanealytics_recommenderlabrats_blob_master_src_implicit.cpp&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Oj62bnDE1oueLU-seL9f0p1xxu4Hvw2JDuP8BUw91c8&m=VTzIWqHqUjsUEq0rJs9u6p5oJdEvwM5rSY7YlYmglGM&s=E57j1meIRKL8m500E49D3PRQ7bgpEv3BgvLJ2Qd6874&e=">
https://github.com/sanealytics/recommenderlabrats/blob/master/src/implicit.cpp</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">(implementing this paper - <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.researchgate.net_profile_Yifan-5FHu_publication_220765111-5FCollaborative-5FFiltering-5Ffor-5FImplicit-5FFeedback-5FDatasets_links_0912f509c579ddd954000000.pdf&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Oj62bnDE1oueLU-seL9f0p1xxu4Hvw2JDuP8BUw91c8&m=VTzIWqHqUjsUEq0rJs9u6p5oJdEvwM5rSY7YlYmglGM&s=jPEJ-O62i5EG_3FH3F3Rdbdj2F_pY3wSDEpb81j3Li0&e=">http://www.researchgate.net/profile/Yifan_Hu/publication/220765111_Collaborative_Filtering_for_Implicit_Feedback_Datasets/links/0912f509c579ddd954000000.pdf</a>)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Matrices C, Y and P are large. Matrix X can be assumed to be small.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I have the following questions -<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">1) I have replaced my BLAS with OpenMP BLAS and am also using the "<span style="font-size:9.0pt;font-family:Consolas;color:#333333">#</span><span style="font-size:9.0pt;font-family:Consolas;color:#A71D5D">pragma</span><span style="font-size:9.0pt;font-family:Consolas;color:#333333">
 omp parallel for</span>" clause. Will they step over each other or are they complimentary? I ask because my understanding is that the for loop will split each user across threads, then the BLAS will redistribute the matrices to multiply across all threads
 again. Is that right? And if so, is that what we want to do?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">2) Since the threads are running in parallel and I just need the resulting value as output, I would ideally like a reduce() that gives each row in sequence and I can construct the new X from it. I am not sure how to go about doing that
 with Rcpp. I also want to avoid copying data as much as possible.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Looking forward to your input,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Saurabh<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>