裝置管理

當設備裝載兩個以上的 CUDA Device ,或是查驗配備的基本規格時可透過以下函數查閱。

 

取得目前機器上,支援 CUDA 的 device 數目,會把結果存在 count 中。函式則會 return 一個 cudaError_t,用來表示 CUDA 的錯誤。

cudaGetDeviceCount( int* count )

 

取得目前機器上第 dev 個 device 的屬性

cudaGetDeviceProperties( cudaDeviceProp* prop, int dev )

 

在目前的 device 中,找一個最符合給定的 prop 的,並把他的索引直存在 dev 裡。

cudaChooseDevice( int* dev, const cudaDeviceProp* prop)

 

指定現在要使用第 dev 個 device。

cudaSetDevice(int dev)

 

取得目前正在使用的 device 的索引編號,儲存在 dev 中

cudaGetDevice(int* dev)

 


顯示當前設備所有 Cuda Device以及其詳細資訊。

void allDeviceInformation(){
	int deviceCount = 0;
	cudaGetDeviceCount(&deviceCount);

	printf("CudaGetDeviceCount : %d \n", deviceCount);
	cudaDeviceProp prop;

	for (int i = 0; i < deviceCount; i++){
		cudaGetDeviceProperties(&prop, i);
		printf("Device Id %d \n", i);
		printf("Device Name : %s \n", prop.name);
		printf("Device 的 Global memory 總量  %d \n", prop.totalGlobalMem);
		printf("Device 的 Shared memory 總量 \n", prop.sharedMemPerBlock);
		printf("每一個 block 的 registers 數量 %d \n", prop.regsPerBlock);
		printf("warp size %d\n", prop.warpSize);
		printf("最大的 memory pitch %d \n", prop.name);
		printf("\n");

		printf("Block 的最大 thread 數 %d \n", prop.maxThreadsPerBlock);
		printf("Block 中 thread 最大的維度 %d,%d,%d \n", prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2]);
		printf("Grid 中 block 的最大維度 %d,%d,%d \n", prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]);
		printf("Device 的 constant memory 總量 %d \n", prop.totalConstMem);
		printf("\n");

		printf("主要版本編號 %d \n", prop.major);
		printf("次要版本編號 %d \n", prop.minor);
		printf("\n");

		printf("clockRate %d \n", prop.clockRate);
		printf("alignment requirement mentioned %d\n", prop.textureAlignment);
		printf("\n");

		printf("\n");
	}
}

 

 

 

arrow
arrow
    文章標籤
    Cuda
    全站熱搜

    Lung-Yu,Tsai 發表在 痞客邦 留言(0) 人氣()