Doubt with parallel_for.

Doubt with parallel_for.

I'm using parallel_for to speed up the filling of two vectors I'm using. The INIT_V1_SIZE and INIT_V2_SIZE variables are read from user input in another place.

class World {


  std::vector v1;

  std::vector v2;

// more things


  World() {

    v1.reserve( INIT_V1_SIZE );

    v2.reserve( INIT_V2_SIZE );

  // more things
  void StartUp() {
  /// more things



FillObjectVector and FillContainerVector iterate through the vector and in each position create a new object. Each object is independent from the rest.
What I want to know if it it possible to launch all of the parallel_for's at the same time. Would it be a good idea?.


4 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de Raf Schietekat
Best Reply

Thanks a lot!!

imagem de jimdempseyatthecove

Depending on the number of memory channels available, if you have two then consider parallel_invoke with each vector listed in the task list using standard for(... to fill/copy the data. On such a system using more than two threads to perform the copy may be counter productive.

Jim Dempsey

Faça login para deixar um comentário.