libstdc++ parallel mode fill

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I recently started using the paralleled version of gcc's libstdc++. I
have a question concerning the fill algorithm.

The threshold variable __gnu_parallel::_Settings::fill_minimal_n
suggests that their is a parallel version of the fill algorithm. Now,
the resize(size_t  n, const T& val = T ()) function of std::vector
seems to use std::fill (via some internal functions) to fill the new
elements of the vector. Although, the resize size function is not
executed in parallel (while sorting elements is) in the following test
program.

#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>

int main (  )
{
        std::vector<int> v;
	v.resize ( 500000000 );
	
	srand ( time(NULL) );
	unsigned int i;
	std::cerr << "Filling..." << std::endl;
	#pragma omp parallel for
	for ( i = 0; i < v.size (); ++i )
	{
		v[i] = rand () % 10 + 1;
	}
	std::cerr << "...done." << std::endl;

	std::cerr << "Sorting..." << std::endl;
	sort ( v.begin (), v.end () );
	std::cerr << "...done." << std::endl;

        return 0;
}

Is this an intended behavior? If yes, why? If not, can I somehow force
the usage of parallel fill?

Thanks in advance.
Best regards,
Kay

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux