对于原因OMP_SET_NUM_THREADS(1)比不慢的OpenMP [英] Reasons for omp_set_num_threads(1) slower than no openmp

查看:235
本文介绍了对于原因OMP_SET_NUM_THREADS(1)比不慢的OpenMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信每个人都同意这个文章的标题。有人能指出我的理由?任何提及,像书等?我试图寻找,但没有运气。

I believe everyone agree with the title of this post. Can someone point me the reason ? Any reference to that like book etc ? I have tried to find but no luck.

我相信原因是一些关于OpenMP拥有同步开销,没有OpenMP的项目没有。

I believe the reason is something about openmp has a synchronization overhead that no openmp project doesn't have.

希望有人能扩大的原因吗?

Hope someone can expand the reason more?

感谢

推荐答案

虽然有一些开销,从使用OpenMP即使只有一个线程运行时,更重要的问题可能是,该code转换的编译器执行产生的OpenMP code(尤其是勾勒出并行区域code到单独的函数[由GCC和ICC进行; PGI做不同的事情...])将影响到其他code优化(如矢量)。
资料编译器在一个单一的功能,可以优化时,code部分中列出的功能执行可能会丢失,所以产生code可能会加重病情。

While there is some overhead at runtime from using OpenMP even with only one thread, the more important issue is likely to be that the code transformations that the compiler has to perform to generate OpenMP code (in particular outlining the parallel region code into separate functions [done by gcc and icc; PGI do something different...]) will be affecting other code optimizations (like vectorization). Information that the compiler has in a single function that allows optimizations potentially gets lost when parts of the code are executed in the outlined functions, so the generated code may be worse.

这篇关于对于原因OMP_SET_NUM_THREADS(1)比不慢的OpenMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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