-1

I've a problem with OpenMP. I'm trying to parallelize the first step of the Counting Sort algorithm: counting the frequencies of all the possibile values (in this case I'm counting the number of neighbors of all vertices of a graph). When I run this code on a small array (e.g. num_vertices = 100k) it works fine. Instead, when the row_ptr array is big (e.g. num_vertices = 1M) i get segmentation fault (or sometimes zsh: bus error).

PS: it works fine also with high number of iteration (e.g. num_edges = 50M) and size(e_list) = num_edges.

#pragma omp parallel for reduction(+: row_ptr[:num_vertices + 2])
    for (uint64_t i = 0; i < num_edges; i++)
        row_ptr[std::get<0>(e_list[i]) + 1]++;

The problem could be the available RAM of the machine or could be something else? Thank you

1 Answers1

0

Arrays used in reduction are reserved on the stack. So, the most probable cause of your problem is that your stack is too small and you have an overflow. Try increasing it by setting the OMP_STACKSIZE environmental variable. If it does not solve your problem, please provide a minimal reproducible example.

Laci
  • 2,738
  • 1
  • 13
  • 22