I have 3 constant values (A
,B
,C
) which I would like to save in the constant memory; I figured out one way to do it by typing this lines of code:
// CUDA global constants
__constant__ int A;
__constant__ int B;
__constant__ int C;
int main(void)
{
float pA=1;
float pB=2;
float pC=3;
...
cudaMemcpyToSymbol(A, &pA, sizeof(A));
cudaMemcpyToSymbol(B, &pB, sizeof(B));
cudaMemcpyToSymbol(C, &pC, sizeof(C));
...
}
However I believe this is not the best way to proceed since it would become very inconvenient if I had a larger number of constants.
Here is my question: how can I replicate the lines of code I wrote above in order to have a more compact form?