alp1
June 7, 2012, 3:13pm
1
Is it possible to have 2D constant arrays?
I want to do something like this
#define NSTREAMS 5
#define MAXCHIPS 525
constant float C0i_dev[NSTREAMS][MAXCHIPS];
float C0i[[NSTREAMS][MAXCHIPS];
err = cudaMemcpyToSymbolAsync(C0i_dev[streamNum], C0i[streamNum], nsubChips*sizeof(float), 0, cudaMemcpyHostToDevice, stream[streamNum]);
if (err) {printf(“error %s in cudaMemcpyToSymbolAsync C0i \n”, cudaGetErrorString(err)); exit(-1);}
But I get a error invalid device symbol error on the memcpy
2D array can be easly converted to 1D array. Tried doing Your stuff this way? It shouldn’t complicate addressing much.
There is one ‘[’ too much at C0i definition…
alp1
June 12, 2012, 11:09am
3
Thanks. The 1D approach was my backup plan. It would have been cleaner code if 2D constant arrays were
allowed. So… are they not allowed?
Any array dimension is allowed, I have used 3D arrays.
alp1
June 12, 2012, 3:06pm
5
Interesting. Maybe the problem was that I was only partially filling the 2D array with
err = cudaMemcpyToSymbolAsync(C0i_dev[streamNum], C0i[streamNum], nsubChips*sizeof(float), 0, cudaMemcpyHostToDevice, stream[streamNum]);
where C0i_dev is the constant memory
Interesting. Maybe the problem was that I was only partially filling the 2D array with
err = cudaMemcpyToSymbolAsync(C0i_dev[streamNum], C0i[streamNum], nsubChips*sizeof(float), 0, cudaMemcpyHostToDevice, stream[streamNum]);
where C0i_dev is the constant memory
I remember that I had problems to only partially fill an array. I was not able to solve the problem.