简体   繁体   English

为什么我的OpenMP实现比单线程实现慢? (跟进)

[英]Why is my OpenMP implementation slower than a single threaded implementation? (Followup)

This is a follow up to Why is my OpenMP implementation slower than a single threaded implementation? 这是为什么我的OpenMP实现比单线程实现慢? .

I have adhered to the answer provided, and used tasking instead of for pragmas to speed up the code. 我已经坚持提供的答案,并使用任务而不是pragma来加速代码。 However, compared to a sequential (same) program, both programs run equally as fast. 但是,与顺序(相同)程序相比,两个程序运行速度相同。 I witness no speed up. 我目睹没有加速。

The reworked code is here: http://pastebin.com/3SFaNEc4 重新编写的代码在这里: http//pastebin.com/3SFaNEc4

I simply removed all the for pragmas and replaced it tasking pragmas for the recursive procedures. 我只是删除了所有for pragma并将其替换为递归过程的任务pragma。

Am I doing anything wrong? 我做错了吗? I should be seeing an almost linear speed up. 我应该看到几乎线性的加速。 What do you guys think? 你们有什么感想?

Thanks! 谢谢!

First - you still have an "#pragma end critical" which should be removed. 首先 - 您仍然应该删除“#pragma end critical”。 It isn't causing a problem, but it is incorrect. 它不会导致问题,但是不正确。 Second - as I said in the other question you posted, you might have to think about how you are parallelizing the code to see the speedup, so just replacing the other pragmas with task pragmas may not speed it up. 第二 - 正如我在你发布的另一个问题中所说的那样,你可能不得不考虑如何并行化代码以查看加速,所以用任务编译指示替换其他编译指示可能无法加快速度。 Third - you haven't put the tasks into a parallel region, so you are not running in parallel at all. 第三 - 您没有将任务放入并行区域,因此您根本不是并行运行。 And you can't just add a parallel region around the tasks or you are going to be doing the same tasks multiple times. 而且,您不能仅在任务周围添加并行区域,或者您将多次执行相同的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM