Note that there are some explanatory texts on larger screens.

plurals
  1. POIf 256 threads give better performance than 8 have I likely got the wrong approach?
    text
    copied!<p>I've just started programming with POSIX threads on dual-core x86_64 Linux system. It seems that 256 threads is about the optimum for performance with the way I've done it. I'm wondering how this could be? And if it could mean that my approach is wrong and a better approach would require far fewer threads and be just as fast or faster?</p> <p>For further background (the program in question is a skeleton for a multi-threaded M-set image generator) see the following questions I've asked already:</p> <p><a href="https://stackoverflow.com/questions/2018746/using-threads-how-should-i-deal-with-something-which-ideally-should-happen-in-se">Using threads, how should I deal with something which ideally should happen in sequential order?</a></p> <p><a href="https://stackoverflow.com/questions/2035758/how-can-my-threaded-image-generating-app-get-its-data-to-the-gui">How can my threaded image generating app get it’s data to the gui?</a></p> <p>Perhaps I should mention that the skeleton (in which I've reproduced minimal functionality for testing and comparison) is now displaying the image, and the actual calculations are done almost twice as fast as the non-threaded program.</p> <p>So if 256 threads running faster than 8 threads is not indicative of a poor approach to threading, how come 256 threads does outperform 8 threads?</p> <p>The speed test case is a portion of the <a href="http://en.wikipedia.org/wiki/Mandelbrot_set" rel="nofollow noreferrer">Mandelbrot Set</a> located at:</p> <pre><code>xmin -0.76243636067708333333333328 xmax -0.7624335575810185185185186 ymax 0.077996663411458333333333929 </code></pre> <p>calculated to a maximum of 30000 iterations.</p> <p>On the <a href="http://jwm-art.net/mdz/" rel="nofollow noreferrer">non-threaded version</a> rendering time on my system is around 15 seconds. On the threaded version, averages speed for 8 threads is 7.8 seconds, while 256 threads is 7.6 seconds.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload