This project is read-only.

Feature request - generate #define's from constants

Jun 26, 2013 at 5:11 PM
Edited Jun 26, 2013 at 5:12 PM
It would be nice to be able to generate kernel-side preprocessor symbols from C#-side constants, like:
static const int SomeVal = 5;

static void myKernel(GThread thread)
var x = SomeVal;
/// do something with SomeVal
and generate this:
#define SOMEVAL 5

extern "C" __global__ void myKernel()
int x = SOMEVAL;
This could help reduce register usage.

(Why, oh why, doesn't C# have a more advanced preprocessor?!?)
Jun 26, 2013 at 5:46 PM
"This could help reduce register usage"

It might. But, are you sure? I mean, if you used a normal const instead of a #define, wouldn't the optimizer end up returning the same compiled code? I kinda suspect that if one would look at a disassembly of both compilations, one wouldn't tell the difference.

"Why, oh why, doesn't C# have a more advanced preprocessor?!?"

Heh I do know what you mean :)