OpenMP、VTune、空闲线程
我使用 VTune 来检查代码的并发性。 这里是输出的屏幕截图。您可以看到,初始阶段有 1 个线程,然后是大约 0.3 秒的密集多线程工作(棕色尖峰),然后是近 3 秒的空闲时间(没有棕色“CPU”,只有绿色“正在运行”)。
知道什么会导致线程处于绿色空闲状态吗?我的代码应该在完成所有密集计算后返回,没有理由再等待 3 秒......
I use VTune to check concurrency of my code. Here is the screen-shot of the output. You can see, that there is some initial period with 1 thread, then ~0.3 sec of intensive multi-thread work (brown spikes) and then almost 3 seconds of idle (no brown "CPU", just green "Running").
Any idea what can cause threads to be in green-idle state? My code should return after doing all intensive computation, there is no cause to wait 3 additional seconds...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果没有分析器,您的程序需要多少时间才能执行?更快吗?查看 VTune 的时间线视图,我的印象是主线程可能正在使用 pthread_exit() 退出 main() 函数,因此 OpenMP 工作线程继续存在,阻止程序完成,直到超时到期并且工作线程确实决定把自己封闭起来。请参阅此处有关 pthread_exit 的讨论。
How much does your program take to execute without the profiler? Is it faster? Looking at the VTune's timeline view I get an impression that the main thread may be exiting main() function using pthread_exit() and so the OpenMP worker threads continue to live preventing the program from finishing until some timeout expires and the worker threads do decide to shut themselves down. See here a discussion on pthread_exit.