Free memory space allocated by a matrix in GPU memory.
gpuFree(gA)
Pointer to a matrix
The user is responsible for memory management ; the purpose of
gpuFree
is to allow to free ressources when a matrix
is not needed anymore in GPU memory.
The available GPU memory is moreless 80% of the total video memory,
when no others applications as video or 3D gaming is executed. A matrix
consumes M*N*4
bits, that is M*N / 2
Bytes.
The functions that consume GPU memory are
gpuAlloc
and gpuSetData
.
//--matrixAdd.cu-- extern "C" __global__ void matrixAdd( double* C, double* A, double* B, int M, int N) { int idx = blockIdx.x; int idy = blockIdx.y; int dx = blockDim.x; int dy = blockDim.y; int tx = threadIdx.x; int ty = threadIdx.y; int x=tx+dx*idx; int y=ty+dy*idy; if(x<M && y<N) C[ x + y*M ]= A[ x + y*M ] + B[ x+ y*M ]; } //--Scilab script-- A=ones(16,16);gA=gpuSetData(A) B=2*ones(16,16);gB=gpuSetData(B) C=0*ones(16,16);gC=gpuSetData(C) bin=gpuBuild(gpuPATH+"/tests/unit_tests/"+"matrixAdd"); fonc=gpuLoadFunction(bin,"matrixAdd") lst=list(gC,gB,gA,16,16) gpuApplyFunction(fonc,lst,16,16,1,1); C=gpuGetData(gC); gpuFree(gA); gpuFree(gB); gpuFree(gC); gpuExit(); | ![]() | ![]() |