Selective nvidia #pragma optionNV(unroll all)

扶醉桌前 提交于 2019-12-10 09:51:55

问题


I'm playing around with nvidia's unroll loops directive, but haven't seen a way to turn it on selectively.

Lets say I have this...

void testUnroll()
{
    #pragma optionNV(unroll all)
    for (...)
        ...
}

void testNoUnroll()
{
    for (...)
        ...
}

Here, I'm assuming both loops end up being unrolled. To stop this I think the solution will involve resetting the directive after the block I want affected, for example:

    #pragma optionNV(unroll all)
    for (...)
        ...
    #pragma optionNV(unroll default) //??

However I don't know the keyword to reset the unroll behaviour to the initial/default setting. How can this be done? If anyone could also point to some official docs for nvidia's compiler directives that'd be even better.


Currently, it seems only the last #pragma optionNV(unroll *) directive found in the program is used (eg throw one in the last line and it overrides everything above it).


回答1:


According to this post on the NVidia forums, having no keyword afterwards will set it to default behavior:

#pragma unroll 1 will prevent the compiler from ever unrolling a loop.

If no number is specified after #pragma unroll, the loop is completely unrolled if its trip count is constant, otherwise it is not unrolled at all.

I'm not sure if it works on GLSL, but you can maybe try:

#pragma optionNV(unroll)

If anyone tries this, let us know if it works!



来源:https://stackoverflow.com/questions/20415815/selective-nvidia-pragma-optionnvunroll-all

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!