并行使用Allgather的另一个嵌套循环的环路
我正在尝试使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来像矩阵矢量乘法。假设您已经分发了
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 fullIN
vector, so you indeed need an allgather for that. You also need to distribute theW0
matrix: each process gets part of thei
indices, and all of thej
indices.