开发者

Global variable touched by a passed-in parameter becomes unusable

folks!

I pass a struct full of data to my kernel, and I run into the following difficulty using it (very stripped down): [edit: mac osx / xcode 3.2 on mac book pro; this compile is obviously for cpu]

typedef struct
    {
    float xoom;
    int   sizex;
    } varholder;

fl开发者_如何学编程oat zX,  xd;

__kernel void Harlan( __global varholder * vh )
    {
    int X = get_global_id(0), Y = get_global_id(1);

    zX = ( ( X - vh->sizex/2 ) / vh->xoom + vh->sizex/2 );  // (a)

    xd = zX;                                                // (b)  BOOM!!
    }

after executing line (a), the line marked (b), a simple assignment, gives "LLVM compiler failed to compile a function".

if, however, we do not execute line (a), then line (b) is fine.

So, through my fiddling around a LOT with this, it seems as if it is the assignment statement (a), which uses a passed-in parameter, that messes up the future access of the variable zX. However, of course I need to be able to use the results of calculations further down the line.

I have zX and xd declared at the file level because my helper functions need them.

Any thoughts? Thanks! David

p.s. I'm now registered so will be able to upvote and accept answers, which I am sadly unable to do for the last person who helped me (used same username to register, but can't seem to vote on the old post; sorry!).


No, say it ain't so!

I am sincerely hoping that this is not a "correct" answer to my own question. I found on another forum (though not the same question asked!) the following, and I am afraid that it refers to what I'm trying to do:

(quote)

You're doing something the standard prohibits. Section 6.5 says:

'All program scope variables must be declared in the __constant address space.'

In other words, program scope variables cannot be mutable.

(end quote)

... well, tcha!!!! What an astoundingly inconvenient restriction! I'm sure there's reasoning behind it.

[edit: Not At All inconvenient! it was in fact astonishingly easy to work around, given a fresh start the next morning. (And no alcohol.)]

You guys & dolls all knew this, right, and didn't have the heart to tell me?...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜