1

I have the following kernel

__global__ void func( float * arr, int N ) {

     int rtid = blockDim.x * blockIdx.x + threadIdx.x;

     if( rtid < N )
    {
        float* row = (float*)((char*)arr + rtid*N*sizeof(float) ); 
        for (int c = 1; c < N; ++c) 
        { 
            //Manipulation
        } 
    } 

}

When I call the kernel from MATLAB using

gtm= parallel.gpu.GPUArray(ones(a,b,'double')); 
OR gtm= parallel.gpu.GPUArray(ones(1,b,'double'));

gtm=k.feval(gtm,b);

it is giving the following error:

Error using ==> feval
parallel.gpu.GPUArray must match the exact input type as specified on the kernel
prototype.

Error in ==> sameInit at 65 gtm=k.feval(gtm,b);

Can someone please tell me where am I going wrong.

Thanking You,

Viharri P L V.

4

1 に答える 1

1

MATLAB で作成されているカーネル オブジェクト "k" の構造は次のとおりです。

 MaxNumLHSArguments: 1
 NumRHSArguments: 2
 ArgumentTypes: {'inout single'  'in int32 scalar'}

上記の CUDA カーネル プロトタイプを使用すると、つまり、

__global__ void func( float * arr, int N )

そのため、不一致エラーが発生しました。CUDA カーネルのプロトタイプを次のように変更する必要があります。

__global__ void func( double * arr, int N )

または、'single' タイプの MATLAB 配列を作成します。

gtm= parallel.gpu.GPUArray(ones(a,b,'single')); 
于 2012-04-12T04:41:31.313 に答える