Hi,
I’m doing my first steps with CUDA. I like it very well. It’s easy to use. You can hardly do anything wrong,
EXCEPT:
Have a look at this code:
[codebox]#if DEVICE_EMULATION
bool InitCUDA(void){return true;}
bool InitCUDA(void)
{
int count = 0;
int i = 0;
cudaGetDeviceCount(&count);
if(count == 0) {
fprintf(stderr, "There is no device.\n");
return false;
}
for(i = 0; i < count; i++) {
cudaDeviceProp prop;
if(cudaGetDeviceProperties(&prop, i) == cudaSuccess) {
if(prop.major >= 1) {
break;
}
}
}
if(i == count) {
fprintf(stderr, "There is no device supporting CUDA.\n");
return false;
}
cudaSetDevice(i);
printf("CUDA initialized.\n");
return true;
}
/************************************************************
************/
/* Example */
/************************************************************
************/
global static void HelloCUDA(char* result, int num)
{
int i = 0;
char p_HelloCUDA[] = "Hello CUDA!";
for(i = 0; i < num; i++) {
result[i] = p_HelloCUDA[i];
}
}
/************************************************************
************/
/* HelloCUDA */
/************************************************************
************/
int main(int argc, char* argv)
{
if(!InitCUDA()) {
return 0;
}
char *device_result = 0;
char host_result[12] ={0};
CUDA_SAFE_CALL( cudaMalloc((void**) &device_result, sizeof(char) * 11));
[/codebox]
It is exactly the code (cut at the end) that came out of the app wizard (http://forums.nvidia.com/index.php?showtopic=80572) (I like this wizard, thanks, kyzhao!).
In my computer there’s an ATI Radeon 9250 PCI (high-end card!!! ;) ).
Now when I step through the code with F11 (in VS2005), a device is said to be found,
although I don’t have an nVidia card. But at the cudaMalloc() call my app suddenly
terminates itself.
I did use the Debug-config set up by the wizard.
What’s going on inside here?
WOULD it work on my ATI card, too (I don’t think so)?