/********************************************************************
* CUDAWin32App10.cu
* This is a example of the CUDA program.
*********************************************************************/
#include
#include
#include
/************************************************************************/
/* Init CUDA */
/************************************************************************/
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 <>= 1) {
break;
}
}
}
if(i == count) {
fprintf(stderr, "There is no device supporting CUDA 1.x.\n");
return false;
}
cudaSetDevice(i);
return true;
}
/************************************************************************/
/* Example */
/************************************************************************/
__global__ static void HelloCUDA(char* result, int num, clock_t* time,int foo)
{
int i = 0;
char p_HelloCUDA[] = "Hello CUDA!";
clock_t start = clock();
for(i = 0; i < time =" clock()" device_result =" 0;" time =" 0;" time_used =" 0;">>>(device_result, 11 , time,1);
cudaMemcpy(&host_result, device_result, sizeof(char) * 11, cudaMemcpyDeviceToHost);
cudaMemcpy(&time_used, time, sizeof(clock_t), cudaMemcpyDeviceToHost);
cudaFree(device_result);
cudaFree(time);
printf("%s,%d\n", host_result, time_used);
return 0;
}
Wednesday, September 10, 2008
Cuda Hello World: Entire Code Listing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment