0

私の元々の問題は、引数のリストが長い関数があり、cudaカーネルに引数として渡すことができるメモリを超えていることです(バイト数は覚えていません。しばらくしてからです)それに対処した)。したがって、この問題を回避する方法は、メンバーが後でカーネル内から逆参照できる他の構造を指すポインターであるという新しい構造を定義することでした。

...これが現在の問題の始まりです。カーネル内からポインター(以前に作成した構造体のメンバー)を逆参照しようとしている時点でCUDA_EXCEPTION_5, Warp Out-of-range Address 、cuda-gdbから...を取得します。それに加えて、cuda-gdbがエラーのあるものとして提供するカーネル名と引数(「この時点では機能しない」と報告されています)は、コードで作成したものではありません。

さて、より詳細については:

関連する構造は次のとおりです。

typedef struct {

    int strx;
    int stry;
    int strz;
    float* el;

} manmat;

typedef struct {

    manmat *x;
    manmat *y;
    manmat *z;

} manmatvec;

メイン内でカーネルの引数をグループ化しようとしている方法は次のとおりです。

int main () {

...
...

    manmat resu0;
    resu0.strx = n+2;       resu0.stry = m+2;       resu0.strz = l+2;
    if (cudaMalloc((void**)&resu0.el,sizeof(float) * (n+2)*(m+2)*(l+2)) != cudaSuccess) cout << endl << " ERROR allocating memory for manmat resu0" << endl ;
    manmat resv0;
    resv0.strx = n+2;       resv0.stry = m+2;       resv0.strz = l+2;
    if (cudaMalloc((void**)&resv0.el,sizeof(float) * (n+2)*(m+2)*(l+2)) != cudaSuccess) cout << endl << " ERROR allocating memory for manmat resv0" << endl ;
    manmat resw0;
    resw0.strx = n+2;       resw0.stry = m+2;       resw0.strz = l+2;
    if (cudaMalloc((void**)&resw0.el,sizeof(float) * (n+2)*(m+2)*(l+2)) != cudaSuccess) cout << endl << " ERROR allocating memory for manmat resw0" << endl ;
    manmatvec residues0 ;

    residues0.x = &resu0;
    residues0.y = &resv0;
    residues0.z = &resw0;

    exec_res_std_2d <<<numBlocks2D, threadsPerBlock2D>>> (residues0, ......) ;

 .....
}

...そしてこれがカーネルで起こることです:

__global__ void exec_res_std_2d (manmatvec residues, ......) {

    int i = blockIdx.x * blockDim.x + threadIdx.x;
    int k = blockIdx.y * blockDim.y + threadIdx.y;

    manmat *resup;
    manmat *resvp;
    manmat *reswp;

    resup = residues.x;
    resvp = residues.y;
    reswp = residues.z;

    manmat resu, resv, resw ;

    resu.strx = (*resup).strx;     //LINE 1626
    resu.stry = (*resup).stry;
    resu.strz = (*resup).strz;
    resu.el = (*resup).el;

    resv = *resvp;
    resw = *reswp;

    .....
}

そして最後に、これはcuda-gdbが出力として提供するものです:

..................
[Launch of CUDA Kernel 1065 (exec_res_std_2d<<<(1,2,1),(32,16,1)>>>) on Device 0]
[Launch of CUDA Kernel 1066 (exec_res_bot_2d<<<(1,2,1),(32,16,1)>>>) on Device 0]

Program received signal CUDA_EXCEPTION_5, Warp Out-of-range Address.
[Switching focus to CUDA kernel 1065, grid 1066, block (0,0,0), thread (0,2,0), device 0, sm 0, warp 2, lane 0]
0x0000000003179020 in fdivide<<<(1,2,1),(32,16,1)>>> (a=warning: Variable is not live at this point. Value is undetermined.
..., pt=warning: Variable is not live at this point. Value is undetermined.
..., cells=warning: Variable is not live at this point. Value is undetermined.
...) at ola.cu:1626
1626    ola.cu: No such file or directory.
    in ola.cu

私は関数を定義していない__device____global__、コードでfdivide....と呼ばれていることに注意する必要があります。

また、デバッガー内でのプログラムの実行の開始時に、cuda cファイルをでコンパイルしているにもかかわらず、次のように言うことが重要かもしれません-arch=sm_20 -g -G -gencode arch=compute_20,code=sm_20

[New Thread 0x7ffff3b69700 (LWP 12465)]
[Context Create of context 0x1292340 on Device 0]
warning: no loadable sections found in added symbol-file /tmp/cuda-dbg/12456/session1/elf.1292340.1619c10.o.LkkWns
warning: no loadable sections found in added symbol-file /tmp/cuda-dbg/12456/session1/elf.1292340.1940ad0.o.aHtC7W
warning: no loadable sections found in added symbol-file /tmp/cuda-dbg/12456/session1/elf.1292340.2745680.o.bVXEWl
warning: no loadable sections found in added symbol-file /tmp/cuda-dbg/12456/session1/elf.1292340.2c438b0.o.cgUqiP
warning: no loadable sections found in added symbol-file /tmp/cuda-dbg/12456/session1/elf.1292340.2c43980.o.4diaQ4
warning: no loadable sections found in added symbol-file /tmp/cuda-dbg/12456/session1/elf.1292340.2dc9380.o.YYJAr5

この問題を解決するのに役立つ回答やヒント、提案は大歓迎です。私は最近cuda-cでプログラミングを始めたばかりであり、cuda-gdbの経験はあまりないことに注意してください。私がCコードで行ったデバッグのほとんどは、コードのさまざまなポイントで出力をチェックすることによって「手動で」行いました。

また、このコードはtesla M2090で実行されており、2.0アーキテクチャで実行するようにコンパイルされています。

4

1 に答える 1

2

これは問題になります:

manmatvec residues0 ;

    residues0.x = &resu0;
    residues0.y = &resv0;
    residues0.z = &resw0;

、、、および変数はresu0、ホストメモリ(ホストスタック)に割り当てられます。ホストアドレスをmanmatvec構造体に入れてから、manmatvecをカーネルに渡します。受信側では、CUDAコードは構造で提供されたホストメモリアドレスにアクセスできません。resv0resw0

resu0、、変数のアドレスを渡す場合はresv0resw0デバイスメモリからそれらを割り当てる必要があります。

これが全体の問題であるかどうかはわかりませんが、それがトップの貢献者であると確信しています。

于 2012-08-29T16:51:00.647 に答える