使用 OpenMP 在 ioquake3 这样的传统单线程游戏引擎上可以实现什么样的优化?

发布于 2024-10-03 09:50:27 字数 103 浏览 0 评论 0原文

您能想出一些方法来对 id tech 3 这样的传统引擎进行重大改进吗?通过尝试在音频子系统上执行此操作,我注意到它会导致速度减慢而不是加速。我怀疑它需要循环计算大量数据,并且很少与核心通信。

Can you think of ways to achieve significant improvement on a traditional engine like id tech 3? By attempting to do it on the Audio Subsystem I noticed it inflicts a slow down rather than a speed up. I suspect it would need big chunks of data to be calculated in loops and only rarely communicate with the core.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜声 2024-10-10 09:50:27

我对 ioquake3 或 id tech 3 一无所知,但对 OpenMP 有一定了解,所以我会立即将问题发回给您。

OpenMP 最初的开发目的是将循环迭代分布在跨处理器的大型数组上,并可访问共享内存。这是大部分科学和工程程序的要求,因此 OpenMP 大量用于此类程序也就不足为奇了。

最近,随着 OpenMP 3.0 的出现,它具有良好的主管/工作人员任务分解功能,从而扩展了其应用范围。我对这些新功能没有太多经验,但它们看起来很有希望。

因此,您面临的问题是:您的计算核心与 OpenMP 支持的计算模型的契合程度如何?

I don't know anything about ioquake3 or id tech 3 but a fair bit about OpenMP so I'll fire the question right back to you.

OpenMP was, initially, developed to distribute loop iterations over large arrays across processors with access to shared memory. This is a requirement in a large fraction of scientific and engineering programs so it will be no surprise that OpenMP is much used for such programs.

More recently, with OpenMP 3.0, it has good facilities for director/worker task decomposition which extend its range of application. I don't have a lot of experience with these new features, but they look promising.

So the question for you is: how well does your computational core fit the model of computation that OpenMP supports ?

假扮的天使 2024-10-10 09:50:27

在处理不依赖于循环中其他元素的数据时,OpenMP 非常有效。例如:

std::vector<int> big_vector(1000, 0);
for (int i = 0; i < big_vector.size(); ++i)
{
    big_vector[i] = i;
}

使用 OpenMP 可以很好地优化,但

std::vector<int> big_vector(1000, 0);
for (int i = 1; i < big_vector.size(); ++i)
{
    big_vector[i] = i * (big_vector[i - 1] + i);
}

不会。

您还可以尝试一下 OpenMP 设置,看看它们是否可以改善您的结果。有关更多信息,http://www.amazon.com/Multi-Threaded-Engine- Design-Jonathan-Harbour/dp/1435454170 有整整一章介绍 OpenMP(以及 boost、posix-threads 和 Windows 线程)。

OpenMP is very effective when operating on data that doesn't depend on other elements in loop. For example:

std::vector<int> big_vector(1000, 0);
for (int i = 0; i < big_vector.size(); ++i)
{
    big_vector[i] = i;
}

would optimize well with OpenMP, but

std::vector<int> big_vector(1000, 0);
for (int i = 1; i < big_vector.size(); ++i)
{
    big_vector[i] = i * (big_vector[i - 1] + i);
}

would not.

You can also play around with the OpenMP settings to see if they improve your results. For more information, http://www.amazon.com/Multi-Threaded-Engine-Design-Jonathan-Harbour/dp/1435454170 has a whole chapter on OpenMP (as well as boost, posix-threads, and Windows Threads).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文