I’m trying to iterate over a map in c++ using openMP, but I got three error messages saying
that the initialization, termination and increment of my loop has improper form and I’m quite new in using openmp, so is there any way to get around this problem while getting the same results as the serial ones? the following is the code I used
map< int,string >::iterator datIt;
#pragma omp parallel for
for(datIt=dat.begin();datIt!=dat.end();datIt++) //construct the distance matrix
{
...............
}
It’s likely your implementation of OpenMP is incompatible with STL iterators. While there have been some changes to the standard to make OMP more compatible with the STL, I think you’ll find your implementation doesn’t support such behaviour. Most OpenMP implementations I’ve encountered are at most version 2.5, Microsoft C++ is 2.0. The only compiler I’m aware of that supports 3.0 is the Intel C++ compiler.
A few other points, you should use std::begin, and std::end. Also, you either need to declare your loop invariant as private, or have OpenMP figure that out by itself, like so:
But without 3.0 support, this is beside the point.