Dynamic initialization

Hi,

I have many const variables that are used by both host and device code. I wanted to change my code such that those variables are read from an ini file during runtime, but the device code has a problem with that. Do I now have to include all those variables as arguments for the kernals or is there another solution?

If you want to read them in from a file at runtime, you will have to do that in host code. Since they are no longer known at compile-time, you will need a method to transfer these values to the device, before executing any kernel that depends on them.

One possibility would be to pass them via kernel parameters - perhaps collect them together into a struct to make things convenient and flexible.

Another possibility would be to use constant memory, and transfer the values to constant memory before executing your kernel. Your kernel can then reference values out of constant memory without passing it explicitly as a kernel parameter.

I’m sure there are other approaches as well.

Thanks for the suggestions.