开发者

What kind of optimizations can be achieved on a traditional single-threaded game engine like ioquake3 with OpenMP?

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开发者_如何学JAVA rarely communicate with the core.


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 ?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜