Skip navigation


Satu hal yang perlu dilakukan setelah melakukan instalasi CUDA Toolkit dkk di komputer (selain program “Hello World!” tentunya) adalah menampilkan device CUDA yang ada di komputer. Hal ini dapat dilakukan dengan memanggil fungsi cudaGetDeviceProperties. Fungsi ini akan mengisi properti dari device yang diinginkan ke dalam sebuah struktur data cudaDeviceProp. Kode sederhananya saya dapatkan dari link ini.

#include <stdlib.h>
#include <stdio.h>
#include <cuda.h>
#include <cuda_runtime.h>

int main(int argc, char **argv)
{
    int ct, dev;
    cudaError_t code;
    struct cudaDeviceProp prop;

    cudaGetDeviceCount(&ct);
    code = cudaGetLastError();
    if (code)
	printf("%s\n", cudaGetErrorString(code));

    if (ct == 0) {
	printf("Cuda device not found.\n");
	exit(0);
    }
    printf("Found %i Cuda device(s).\n", ct);

    for (dev = 0; dev < ct; ++dev) {
	printf("Cuda device %i\n", dev);

	cudaGetDeviceProperties(&prop, dev);
	printf("\tname : %s\n", prop.name);
	printf("\ttotalGlobablMem: %lu\n",
	       (unsigned long) prop.totalGlobalMem);
	printf("\tsharedMemPerBlock: %i\n", prop.sharedMemPerBlock);
	printf("\tregsPerBlock: %i\n", prop.regsPerBlock);
	printf("\twarpSize: %i\n", prop.warpSize);
	printf("\tmemPitch: %i\n", prop.memPitch);
	printf("\tmaxThreadsPerBlock: %i\n", prop.maxThreadsPerBlock);
	printf("\tmaxThreadsDim: %i, %i, %i\n", prop.maxThreadsDim[0],
	       prop.maxThreadsDim[1], prop.maxThreadsDim[2]);
	printf("\tmaxGridSize: %i, %i, %i\n", prop.maxGridSize[0],
	       prop.maxGridSize[1], prop.maxGridSize[2]);
	printf("\tclockRate: %i\n", prop.clockRate);
	printf("\ttotalConstMem: %i\n", prop.totalConstMem);
	printf("\tmajor: %i\n", prop.major);
	printf("\tminor: %i\n", prop.minor);
	printf("\ttextureAlignment: %i\n", prop.textureAlignment);
	printf("\tdeviceOverlap: %i\n", prop.deviceOverlap);
	printf("\tmultiProcessorCount: %i\n", prop.multiProcessorCount);
    }
}

Tinggal kompilasi kode ini dengan nvcc

$nvcc -o deviceprop deviceprop.c
$./deviceprop

Hasil keluarannya untuk komputer pribadi saya

Found 1 Cuda device(s).
Cuda device 0
	name : GeForce GTS 250
	totalGlobablMem: 1073020928
	sharedMemPerBlock: 16384
	regsPerBlock: 8192
	warpSize: 32
	memPitch: 2147483647
	maxThreadsPerBlock: 512
	maxThreadsDim: 512, 512, 64
	maxGridSize: 65535, 65535, 1
	clockRate: 1912000
	totalConstMem: 65536
	major: 1
	minor: 1
	textureAlignment: 256
	deviceOverlap: 1
	multiProcessorCount: 16

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: