Massive slowdown in search_n in parallel mode

Chris Jefferson
Mon Nov 26 10:24:00 GMT 2007

On 23/11/2007, Johannes Singler <> wrote:
> Hi Chris,
> > I decided to try compiling my code in 'parallel mode', hoping to make
> > use of my 2 core machine. I was somewhat suprised to see my code slow
> > down about 50 times or so.
> >
> ...
> Well, it is basically calling search() with a pseudo-sequence of n equal
> elements. The Knuth-Morris-Pratt algorithm built into search() should be
> able to analyze this and to advance in large steps, about n in this
> case, leading to O(l/n) running time again.

Just to reply to this message, after a bit of off-list discussion, it
turns out my code wasn't completely threadsafe.


More information about the Libstdc++ mailing list