What type of cuda memory is a parameter?

I declare a parameter variable like so:

integer, parameter :: para1

which then gets used in a cuda kernel. Does it reside in constant memory, or somewhere else?

Hi Tom,

Parameter variables are typically replaced by the literal constant value and the variable removed. No storage would be crated, either in constant memory or elsewhere.

Hope this helps,
Mat

Thanks, yeah that helps
-Tom

Mat,

So, if we had constants that were in “constant” memory, but could be included in the code as parameters, that might be best? We’d save on host-to-CPU traffic because the variables were hard-coded by the compiler?

Matt

Hi Matt,

I haven’t look at this specifically, but my guess is that it would help (or at least not hurt). How much? probably not a lot. Worth an experiment.

The only caveat would be in the cases where storage needed to be created, such if your passing the parameter or if compiling with -g. Unlikely in this scenario, however.

  • Mat

My only thought was I know in some of my code sending over a lot of constants means a lot of DMA transfers since most of my constants are not in derived data types. I have to believe 10 DMA transfers is better than 30.

Then again, need to test the timings to be sure. Maybe the constant broadcast has benefits that outweigh the DMA cost?

Thanks,
Matt