Retrieve a matrix stored in GPU memory, and convert it to Scilab's matrix.
A=gpuGetData(gA)
Pointer on the matrix stored in GPU memory.
A real matrix
A=gpuGetData(gA)
allow users to retrieve a matrix
stored in GPU memory in order to get, for instance, the result of a kernel
launch. A gpu kernel can only be applied to data stored in GPU
memory.
gA
encapsulate a pointer to a matrix stored in
GPU memory. It is seen as a double*
in the gpu
langage. Such a value is generated by gpuSetData
, and is
after passed to gpuApplyFunction in order to launch a Kernel.
//--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(); | ![]() | ![]() |