GDB tells me that the sigsegv occurs at the call to operator[] of my vector.
My vector is defined before a parallel region with 2 threads, one of them is only calling push_back, and the other is only reading (so it is calling [] and size() )
I have called .reserve() with enough memory before the parallel region, so no reallocation should happen. When the thread 2 wants to reads at index i, it ensures that the size of the vector is at least i+7 (by calling size()), so no out of bound error should be the reason.
The way the n threads are created is like this :
vector<string> myvector;
#pragma omp parallel for num_threads(n)
for (int i=0; i<n; i++)
{
if (i==0)
do_stuff, sometimes calls myvector.push_back();
else
do stuff2, sometimes call myvecttor[j] after checking myvector.size() > j+7
}
Aucun commentaire:
Enregistrer un commentaire