Parallel_for设计和实现问题 [英] Parallel_for design and implementation issues

查看:90
本文介绍了Parallel_for设计和实现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Hello everyone,

推荐答案

哈里斯,

您已经正确识别了用于模式的构造.内部循环将全部在同一线程上运行,并且不会按预期共享其数据.  查看您的代码,您似乎丢失了在外部 循环.

You've correctly identified the constructs to be used for the pattern. The inner loop will all run on the same thread and not share its data as you expect.  Looking at your code, you seem to be missing calling the combine method after the outer for loop.

循环后,您只需调用:

sum = sums.combine();

sum = sums.combine();

 

您可以确认是否可以解决该问题?

Can you confirm if this fixes the issue?

此致

Rahul


这篇关于Parallel_for设计和实现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆