I have a vector of vector. I construct this vector in a parallel manner with each index in the vector being dealt with by a single thread. Something similar to this :
vector<vector<int> > global_vec(10, vector<int>({}));
#pragma omp parallel for schedule(dynamic)
for(int i = 0; i < 10; i++)
{
for(int j = 0; j < i * 5; j++)
{
global_vec[i].push_back(i);
}
}
Run Code Online (Sandbox Code Playgroud)
I know if I had known the size of each vector beforehand, I could have allocated …