global constant floats shared in device code with Visual Studio

I have this exact issue posed on Stack Overflow but this was never answered. I figured it would be more appropriate to ask here.

Essentially I have a header with global float constants I want to share between host and device code. Seems pretty straight forward thing to want to do. However, on Windows (VC11) only, I get ‘identifier “X” is undefined in device code’.

There is a similar question posed here which I sort of understand that says the issue is that I’m declaring memory in the host and the gpu which isn’t allowed.

So does this just happen to work on gcc (linux) and clang (OS X) because somehow the host compiler is doing things differently there?

  • James

It’s a documented limitation of attempting to use this with the visual studio host compiler:

You’ll need to find another approach to using a global float (or double) constant this way (on windows)

Yes, somehow the host compiler matters.