如何把这段代码改成OMP多线程代码?谢谢

situjunc 2016-02-13 10:01:14
额,有一个三维数组h[2][100][100],其实就是两个二维数组h[0][99][99]和h[1][99][99]。
其中h[0][49][49]=100,h[1][49][49]=100。剩下的所有数据初始化为20。执行下面的迭代代码后,就会数据就会改变。其实就是热量散布问题啦.....
现在要怎么把这段顺序改成#pragma omp parallel 这种并行代码呢?谢谢

for (iteration = 0; iteration < 999; iteration++) {
for (i = 1; i < 99; i++){
for (j = 1; j < 99; j++){
h[next][i][j] = 0.25 * (h[current][i-1][j] + h[current][i+1][j] + h[current][i][j-1] + h[current][i][j+1]);
}
}
current = next; // swap values of current and next
next = 1 - current;
}
...全文
946 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

566

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧