<< gpuOnes sciGPGPU gpuSize >>

sciGPGPU >> sciGPGPU > gpuSetData

gpuSetData

Upload a Scilab matrix to the GPU memory

Call sequence

gA=gpuSetData(A)

Parameters

A

Real/Complex matrix

gA

Pointer to a matrix stored in GPU memory.

Description

gA=gpuSetData(A)

gA=gpuSetData(A) is used when the user wants to launch a computation using its GPU. GPU needs to have its data in GPU memory. The value returned is equivalent to a double* in C for gpu.

gAis equivalent to a double* in C for gpu. It can be passed to Scilab GPU functions.

Exemples

//--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",16,16,1,1)
fonc(gC,gB,gA,int32(16),int32(16))
C=gpuGetData(gC);
clear gA;
clear gB;
clear gC;
gpuExit();

See Also


Report an issue
<< gpuOnes sciGPGPU gpuSize >>