选择性nvidia #pragma optionNV(全部展开) [英] Selective nvidia #pragma optionNV(unroll all)

查看:237
本文介绍了选择性nvidia #pragma optionNV(全部展开)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用nvidia的unroll loops指令,但是还没有找到一种有选择地打开它的方法.

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) //??

但是我不知道将展开行为重置为初始/默认设置的关键字. 这怎么办?如果有人还能指出一些有关NVIDIA编译器指令的官方文档,那就更好了.

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.

当前,似乎只使用了程序中找到的最后一个#pragma optionNV(unroll *)指令(例如,在最后一行中抛出一个指令,它将覆盖上面的所有内容).

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

推荐答案

根据

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

#pragma展开1将阻止编译器展开循环.

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

如果#pragma展开后未指定任何编号,则循环的跳变计数为常数时将完全展开,否则根本不会展开.

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.

我不确定它是否可以在GLSL上运行,但是您可以尝试:

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!

这篇关于选择性nvidia #pragma optionNV(全部展开)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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