samedi 28 mars 2015

CUDA elegant solution for large number of parameters


The problem I've been seeing in examples online and in my own code is what to do when you have a large number of global parameters (usually constants, but they are dependent on the initialization of the simulation).


It seems like some people choose to wrap them into a struct and then pass the pointer to the struct to every function call (which seems quite annoying) or you can declare a whole bunch of empty __device__ or __constant__ variables and then fill them with some sort of wrapper initialization code (also pretty annoying since you have duplicate code).


It can get particularly messy when you have global functions that then call device functions which all need access to different parameters.


I am wondering if there is a more elegant solution and what the actual "standard" (if there is one) or at least more accepted way of dealing with this is.




Aucun commentaire:

Enregistrer un commentaire