OPNEMP分割故障使用大型阵列上的减少

发布于 2025-02-08 22:05:23 字数 481 浏览 1 评论 0原文

我对OpenMP有问题。我正在尝试并行化计数排序算法的第一步:计数所有可能值的频率(在这种情况下,我正在计算图形所有顶点的邻居数)。 当我在小数组(例如num_vertices = 100k)上运行此代码时,它可以正常工作。相反,当ROW_PTR数组很大时(例如Num_vertices = 1M),我会得到分段故障(或有时ZSH:BUS错误)。

PS:它的工作正常也可以使用,并且具有大量迭代(例如num_edges = 50m)和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]++;

问题可能是机器的可用公羊,或者可能是其他的? 谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦一生花开无言 2025-02-15 22:05:23

减少的阵列保留在堆栈上。因此,问题的最可能原因是您的堆栈太小,并且您的溢出溢出。尝试通过设置 opt_stacksize 环境可变。如果无法解决您的问题,请提供

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文