并行使用Allgather的另一个嵌套循环的环路

发布于 2025-01-20 22:04:40 字数 226 浏览 3 评论 0原文

我正在尝试使用Allgather在此处平行于嵌套的循环

for (int i=0; i<N1; i++) {
        for (int j=0; j<N0; j++)
            HS_1[i] += IN[j]*W0[j][i];
    }

,而N1是1000,N2为764。

我有四个过程,我只想并行化外圈。有办法做到吗?

I am trying to parallelize a nested for loop below using allgather

for (int i=0; i<N1; i++) {
        for (int j=0; j<N0; j++)
            HS_1[i] += IN[j]*W0[j][i];
    }

Here N1 is 1000 and N2 is 764.

I have four processes and I just want to parallelize the outer loop. Is there a way to do it?

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

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

发布评论

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

评论(1

背叛残局 2025-01-27 22:04:40

这看起来像矩阵矢量乘法。假设您已经分发了hs输出向量。每个组件都需要向量中的完整,因此您确实需要一个Allgather。您还需要分发W0矩阵:每个过程都将获得i indices的一部分,以及所有j indices。

This looks like a matrix-vector multiplication. Let's assume that you've distributed the HS output vector. Each component needs the full IN vector, so you indeed need an allgather for that. You also need to distribute the W0 matrix: each process gets part of the i indices, and all of the j indices.

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