1. Cuda 지원 디바이스 개수 조회
다음은 cuda 지원 디바이스 개수를 조회하는 API 이다.
다음과 같이 사용한다.
int count;
cudaGetDeviceCount(&count);
2. Cuda 지원 디바이스 정보 조회
다음은 cuda 지원 디바이스의 정보를 조회하는 API 이다.
cudaDeviceProp 구조체는 다음의 URL에서 각 멤버에 대한 설명을 찾을 수 있다.
http://docs.nvidia.com/cuda/cuda-runtime-api/structcudaDeviceProp.html#structcudaDeviceProp
다음과 같이 사용한다.
cudeDeviceProp prop;
cudaGetDeviceProperties(&prop,0);
//여기에서 0은 Cuda 디바이스 Number이다. cudaGetDeviceCount 에서 리턴받은 개수 만큼 지정
3. 특정 Property를 가진 Cuda 디바이스 조회
cudaDeviceProp 를 선언하고 구조체의 값을 채운후 cudaChooseDevice에 전달하면 이 조건에 만족하는 디바이스를 검색하게 해준다.
다음과 같이 사용한다.
int device;
cudaDeviceProp prop;
memset(&prop,0,sizeof(cudaDeviceProp));
prop.major=3;
prop.minor=0;
cudaChooseDevice(&device,&prop);//이때 device에 조건을 만족하는 cuda device number를 전달한다.
4. 특정 cuda device 이용
5. 예제
다음은 cuda device 0번에서 메모리 사이즈를 가져오는 예제이다.
#include <stdio.h> |
실행 결과는 다음과 같다 (GTX760 의 메모리 4G 버전임)
./deviceQuery
Total global mem:4294246400
Total Constant Mem:65536