I wish to iterate through all the elements in a std::multimap in parallel using OpenMP.
I tried to compile the following code using g++-7 (7.2.0) and icpc (18.0.0 20170811), but both failed.
Is this possible? If so, how can I parallelize a for-loop through a C++ std::multimap using OpenMP?
#include <map>
#include <omp.h>
int main() {
std::multimap<int,int> myMultimap;
for (int i = 0; i < 10; ++i){
myMultimap.insert(std::make_pair(i,i+1)); // create dummy contents
}
std::multimap<int, int>::const_iterator itr;
#pragma omp parallel for private (itr)
for (itr = myMultimap.cbegin(); itr != myMultimap.cend(); ++itr) {
// do something here
}
return 0;
}