<div dir="ltr"><div>Hello friends,</div><div><br></div><div>I have been working on the OpenMP backend for the parallel STL, and most of the tests are passing. However, among the failures is the "is_partitioned" test. I have rewritten the __parallel_reduce backend function to be simpler to understand in an attempt to understand what is failing (code is below.)</div><div><br></div><div>I also rewrote it as a serial function that splits the iteration range in two and then calls __reduction() on each half of the range being passed in. The result I get from the serial execution as compared to the result I get from the parallel execution is different.</div><div><br></div><div>I have verified that the parallel execution tasks are run, and that their results match what each serial execution would be if I ran them that way.</div><div><br></div><div>I am wondering if there is something wrong with the way OpenMP is running the reducer here? Perhaps it is injecting a value into the computation that is unexpected for this algorithm? Does anything jump out at anyone as being suspicious?</div><div><br></div><div>Thank you again for your time and assistance!</div><div><pre style="color:rgb(8,8,8);font-family:"JetBrains Mono",monospace;font-size:11.3pt"><span style="color:rgb(0,51,179)">template </span><<span style="color:rgb(0,51,179)">class </span><span style="color:rgb(55,31,128)">_RandomAccessIterator</span>, <span style="color:rgb(0,51,179)">class </span><span style="color:rgb(55,31,128)">_Value</span>, <span style="color:rgb(0,51,179)">typename </span><span style="color:rgb(55,31,128)">_RealBody</span>, <span style="color:rgb(0,51,179)">typename </span><span style="color:rgb(55,31,128)">_Reduction</span>><br><span style="color:rgb(55,31,128)">_Value<br></span><span style="color:rgb(0,98,122)">__parallel_reduce_body</span>(<span style="color:rgb(55,31,128)">_RandomAccessIterator </span>__first, <span style="color:rgb(55,31,128)">_RandomAccessIterator </span>__last, <span style="color:rgb(55,31,128)">_Value </span>__identity,<br>                       <span style="color:rgb(55,31,128)">_RealBody </span>__real_body, <span style="color:rgb(55,31,128)">_Reduction </span>__reduction)<br>{<br>    std::size_t <span style="color:rgb(0,0,0)">__item_count </span>= __last - __first;<br>    std::size_t <span style="color:rgb(0,0,0)">__head_items </span>= (__item_count / __default_chunk_size) * __default_chunk_size;<br><br>    <span style="color:rgb(140,140,140);font-style:italic">// We should encapsulate a result value and a reduction operator since we<br></span><span style="color:rgb(140,140,140);font-style:italic">    // cannot use a lambda in OpenMP UDR.<br></span><span style="color:rgb(140,140,140);font-style:italic">    </span><span style="color:rgb(0,51,179)">using </span><span style="color:rgb(55,31,128)">_CombinerType </span>= <span style="color:rgb(0,128,128)">__pstl</span>::<span style="color:rgb(0,128,128)">__internal</span>::<span style="color:rgb(0,128,128)">_Combiner</span><<span style="color:rgb(55,31,128)">_Value</span>, <span style="color:rgb(55,31,128)">_Reduction</span>>;<br>    <span style="color:rgb(55,31,128)">_CombinerType </span><span style="color:rgb(0,0,0)">__result</span>{__identity, &__reduction};<br>    _PSTL_PRAGMA_DECLARE_REDUCTION(__combiner, _CombinerType)<br><br>    <span style="color:rgb(140,140,140);font-style:italic">// To avoid over-subscription we use taskloop for the nested parallelism<br></span><span style="color:rgb(140,140,140);font-style:italic">    //_PSTL_PRAGMA(omp taskloop reduction(__combiner : __result))<br></span><span style="color:rgb(140,140,140);font-style:italic">    </span><span style="color:rgb(0,51,179)">for </span>(std::size_t __i = <span style="color:rgb(23,80,235)">0</span>; __i < __item_count; __i += __default_chunk_size)<br>    {<br>        <span style="color:rgb(0,51,179)">auto </span>__begin = __first + __i;<br>        <span style="color:rgb(0,51,179)">auto </span>__end = __i < __head_items ? __begin + __default_chunk_size : __last;<br>        __result.__value = __real_body(__begin, __end, __identity);<br>    }<br><br>    <span style="color:rgb(0,51,179)">return </span><span style="color:rgb(0,0,0)">__result</span>.<span style="color:rgb(0,0,0)">__value</span>;<br>}    </pre></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="RU"><div><div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt"><div><div><div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt"><div><div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>

</blockquote></div>
</blockquote></div></div>