'Getting invalid pointer error for openmp parallel code
I am trying to compute the number of triangles for each edge in an OpenMP parallel code. Following is the code snippet where I am doing it. While running with multiple OpenMP threads, once in a while I am getting the following error
munmap_chunk(): invalid pointer: 0x00000100002500e0 ***
However, when I am running in a single thread, I am not getting any errors. Any suggestions on what's wrong with the code?
///graph is declared as follows map<int, std::map<int, Edge>> graph, where the first key is the vertex u and the keys of the second map are all the adjacent vertices
int smax = 0;
#pragma omp parallel for reduction(max:smax)
for(int i = 0; i < vertexIds.size(); i++) //vertexIds is a vector of all the vertices
{
int u = vertexIds[i];
for(map<int, Edge>::iterator it2 = graph[u].begin(); it2 != graph[u].end(); it2++)
{
int v = it2->first;
Edge edge = it2->second;
if(u < v)
{
if(tricount.find(edge) == tricount.end()) //tricount is a map for storing number of triangles for each edge
{
int s = 0;
for(map<int, Edge>::iterator it3 = graph[u].begin(); it3 != graph[u].end(); it3++)
{
int w = it3->first;
if(v != w)
{
if(graph[v].find(w) != graph[v].end())
{
s++;
}
}
}
if (s > smax)
{
smax = s;
}
tricount.insert(make_pair(edge, s));
}
}
}
}
return smax;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
