I have a problem.
Im reading in a picture of grey float values, that will be passed to following method in a *cu file
extern “C” void doCudaStuff(int data_h, int width, int height){
const int N = heightwidth; // Number of elements in arrays
int *data_d;
size_t size = N * sizeof(int);
cudaMalloc((void **) &data_d, size);
… that follows the standard procedure, i know from my results that the data_h array cannot be empty, though the test
for(int i = 0; i < 15;i++){
printf(“%d %f\n”, i, data_h[i]);
}
and the succedinmg device array test fail
cudaMemcpy(data_d, data_h, size, cudaMemcpyHostToDevice);
for(int i = 0; i < 15;i++){
printf(“%d \n”, data_d[i]);
}
all i get is Zeros for the first 15 elements, although they should be filled with 0 <= value <= 255
Thank you very much, that sounds logical
but still the problem remains
extern “C” void doCudaStuff(int *data_h, int width, int height){
const int N = height*width; // Number of elements in arrays
int *data_d;
size_t size = N * sizeof(int);
cudaMalloc((void **) &data_d, size);
for(int i = 0; i < 15;i++){
printf(“%d %f\n”, i, data_h[i]);
}
data_h is my host array, the method is still executed in Host code, residing withing the cu file
why cant i print the data from the host array in the first place?? :(
I just happen to have another question concerning the acessability of arrays
if i pass my in host code initialized Array to a Kernel, the GPU will not be able to read from it, since it was initialized in Host code or?
So the kernel can only access variables allocated from HostToDevice , right?