<div dir="ltr">Hi Enea,<div><br></div><div>I have installed the developmental version of ppl and configured it with thread-safety on. It seems to work just as you say it will, but I am having issues getting the expected speedups. To demonstrate the speedup issue, I have included a sample program below. This program creates a user inputted number of threads, and in each thread it intersects two NNC_Polyhedron a user inputted number of times. For timing comparisons, I also made a code path in the test program that does not call PPL but rather computes logarithms. </div><div><br></div><div><div>#include <ppl.hh></div><div>#include "Thread_Pool_defs.hh"</div><div><br></div><div>using namespace Parma_Polyhedra_Library;</div><div>namespace Parma_Polyhedra_Library {using IO_Operators::operator<<;}</div><div>using namespace std;</div><div><br></div><div>void TestIntersections(int RepCount, bool TestPPL) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>double x = 10.0;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>double b = 0.0;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>for (size_t i = 0; i != j; k++) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>if (TestPPL == false) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                        </span>x += i;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                        </span>b += log(x);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">           </span>} else {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>Variable x0(0);Variable x1(1);Variable x2(2);Variable x3(3);Variable x4(4);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                    </span>Variable x5(5);Variable x6(6);Variable x7(7);Variable x8(8);Variable x9(9);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                    </span>Constraint_System cs1;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                 </span>cs1.insert(x8-x9==0);cs1.insert(x2-x9>=0);cs1.insert(x3-x9>=0);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                  </span>cs1.insert(x4-x9>=0);cs1.insert(x5-x9>=0);cs1.insert(x1-x9>=0);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>cs1.insert(x6-x9>=0);cs1.insert(x7-x9>=0);cs1.insert(x0-x9>=0);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>NNC_Polyhedron ph1(cs1);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>Constraint_System cs2;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                 </span>cs2.insert(x7-x9==0);cs2.insert(x2+x3-x8-x9>=0);cs2.insert(x1+x2-x8-x9>=0);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>cs2.insert(x3+x4-x8-x9>=0);cs2.insert(x0-x8>=0);cs2.insert(x5+x6-x8-x9>=0);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                   </span>cs2.insert(x6-x8>=0);cs2.insert(x0+x1-x8-x9>=0);cs2.insert(x4+x5-x8-x9>=0);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                   </span>NNC_Polyhedron ph2(cs2);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>NNC_Polyhedron ph3(cs1);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>ph2.add_constraints(ph2.minimized_constraints());</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>ph2.minimized_constraints();</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                   </span>ph2.affine_dimension();</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>};</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>};</div><div>}</div><div><br></div><div>int main(int argc, char* argv[]) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>int TotalProcessCount = atoi(argv[1]);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>int RepCount = atoi(argv[2]);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>bool TestPPL = atoi(argv[3]);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>typedef std::function<void()> work_type;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Thread_Pool<work_type> thread_pool(TotalProcessCount);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>for (size_t i = 0; i != TotalProcessCount; i++) {</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>work_type work = std::bind(TestIntersections, RepCount, TestPPL);</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>thread_pool.submit(make_threadable(work));</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>};</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>thread_pool.finalize();</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>return 0;</div><div>}</div></div><div><div><br></div><div>This is how I compiled:</div><div>g++ -std=c++11 -pthread file_name.cpp -l:libtcmalloc_minimal.so.4.2.6 -lppl -lgmpxx -lgmp<br></div></div><div><br></div><div><br></div><div>I tested this on a new machine with 44 cores and hyperthreading (thread::hardware_concurrency() = 88), run with RepCount = 10,000 and TestPPL = true. Here are the timings:</div><div>#thread,real time (from time)<br></div><div><div>1,0m0.925s</div><div>5,0m1.820s</div><div>10,0m3.041s</div><div>20,0m3.758s</div><div>40,0m6.775s</div></div><div><br></div><div><br></div><div>By way of comparison, here are the timings for RepCount = 50,000,000 and TestPPL = false:</div><div><div>#thread,real time (from time)</div><div></div></div><div>1,0m1.767s</div><div>5,0m1.854s</div><div>10,0m2.012s</div><div>20,0m2.139s</div><div>40,0m2.206s</div><div><br></div><div>Assuming sufficient hardware, I would expect it to take the same amount of time for 1 thread as 40 threads, though I know that that is not quite realistic. Am I doing something incorrectly in the PPL code branch that is causing it to slow down so much as the number of threads increases? I am not very experienced with parallel C++ programming, so please forgive me if I am doing something foolish. Thanks so much for all of the help.<br></div><div><br></div><div><br></div><div>Best,</div><div>Jeff</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 8, 2016 at 4:15 AM, Enea Zaffanella <span dir="ltr"><<a href="mailto:zaffanella@cs.unipr.it" target="_blank">zaffanella@cs.unipr.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <p>Hello John.<br>
    </p><span class="">
    <br>
    <div class="m_5829183184981424086moz-cite-prefix">On 10/07/2016 06:54 PM, John Paulson
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Hi Enea and Roberto,
        <div><br>
        </div>
        <div>Thank you very much for all of the work you have done on
          threading with PPL. I have a couple of questions about the
          current status of the thread safety. A project I am currently
          working on needs to have multiple threads working
          simultaneously on distinct PPL objects. Is that possible with
          the new thread safe version?</div>
      </div>
    </blockquote>
    <br></span>
    Yes, it is possible.<br>
    <br>
    If the PPL objects are distinct, so that there is no concurrent
    access to the *same* object, then things should not be difficult
    (e.g., no need at all for synchronization). You can have a look to
    the ppl_lcdd and ppl_lpsol demos or to the recently added tests in
    tests/Polyhedron/threadsafe*.<wbr>cc<span class=""><br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>I made an implementation of my current project where I fork
          processes instead of using multiple threads. However, if I
          fork and have two processes manipulating distinct PPL objects,
          I do not get a speedup by a factor of two like I would expect.
          Is there anyway to get that type of speedup?</div>
      </div>
    </blockquote>
    <br></span>
    If you use many process, then the PPL should be working fine "as is"
    (i.e., with thread-safety off).<br>
    As for the missing speedup, I doubt it has something to do with the
    library:<br>
    there should be something else going on, but I have no information
    to guess what it could be.<br>
    <br>
    Cheers,<br>
    Enea.<br>
    <br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Best,</div>
        <div>John C. Paulson</div>
      </div>
      <br>
      <fieldset class="m_5829183184981424086mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
PPL-devel mailing list
<a class="m_5829183184981424086moz-txt-link-abbreviated" href="mailto:PPL-devel@cs.unipr.it" target="_blank">PPL-devel@cs.unipr.it</a>
<a class="m_5829183184981424086moz-txt-link-freetext" href="http://www.cs.unipr.it/mailman/listinfo/ppl-devel" target="_blank">http://www.cs.unipr.it/<wbr>mailman/listinfo/ppl-devel</a>
</pre>
    </blockquote>
    <br>
  </div>

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