Hi guys, I’m having a little problem with a CUDA program I’m writing.
The problem actually occurs before anything is sent to the GPU so apologies if this is the wrong forum
(figured I would try this since I’m using nvcc)
The problem is that as soon as I set/change the elements of an array and print them out to console, I get the segmentation fault.
The array is declared CPU side (i.e. resides in host memory) and is only being accessed by CPU (the fault occurs so close at the beginning of the program that no CUDA stuff is being done yet).
float v[6];
for(int i = 0; i < 6; ++i) {
v[i] = 0;
}
for(int i = 0; i < 6; ++i) {
cout << v[i] << " ";
}
At the moment, this is the only stuff in main thats not commented out, the rest of the code is. (I would have just one line not commented out and try compile, if all is ok then un-comment out the next line too and compile etc etc to see which exact line cause the segmentation fault, the fault seems to occur after the last loop so the rest of the code in still commented out and hence omitted from the post)
(Note: generic array name and magic number used purposely since this code may be used in a project…assuming it eventually works)
And the console print out: