1

問題は解決しました (興味がある場合は、行の下の 2 番目の段落を参照してください)。ここで、新しい質問があります。#define BLOCK_DIM 16; 以下の関数でエラーが発生するのはなぜですか? 使うだけ16でいい。

ここにエラーがあります

     expected a "]"
      __local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;
                           ^

     line 110: error:
              expected a ")"
      __local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;
                                        ^

     line 110: error: operand
              of "*" must be a pointer
      __local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;

error:
          expected a ";"
          int Idout = get_local_id(0)*(BLOCK_DIM+1)+get_local_id(1);
                                                  ^

と関数

    __kernel void   transpose(
             __global float2* dataout, 
             __global float2* datain, 
             int width, int height)

// width = N (signal length) 
// height = batch_size (number of signals in a batch)

{
// read the matrix tile into shared memory

__local float2 block[32 * (32 + 1)] ;
   unsigned int xIndex = get_global_id(0);
   unsigned int yIndex = get_global_id(1);

    if((xIndex < width) && (yIndex < height))
    {
            unsigned int index_in = yIndex * width + xIndex;
                       int Idin = get_local_id(1)*(32+1)+get_local_id(0);
                       block[Idin]=  datain[index_in];
    }

barrier(CLK_LOCAL_MEM_FENCE);

// write the transposed matrix tile to global memory

             xIndex = get_group_id(1) * 32 + get_local_id(0);
             yIndex = get_group_id(0) * 32 + get_local_id(1);

    if((xIndex < height) && (yIndex < width))
    {
        unsigned int index_out = yIndex * height + xIndex;
        int Idout = get_local_id(0)*(32+1)+get_local_id(1);
                dataout[index_out] = block[Idout];
    }

}

===============================

画像の 2D FFT のパフォーマンスを改善するために取り組んでいます。ベンチマーク後; 転置機能がプログラムを遅くする理由だと認識しているので、より最適化されたものに置き換えます。

しかしその後; 以前は正常に動作していたすべての機能のリターン コードを受け取りましたCL_INVALID_KERNEL_NAME。転置関数とclSetKernelArgホスト コードを除きます。私は他に何も変更しません。だから私は考えていません。皆さんが私を助けてくれることを願っています:)

更新: ここにエラーがあります。行番号は気にしないでください :) これらの行は私には普通のようです。何か問題がありますか?

エラー:

     expected a "]"
      __local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;
                           ^

     line 110: error:
              expected a ")"
      __local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;
                                        ^

     line 110: error: operand
              of "*" must be a pointer
      __local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;

error:
          expected a ";"
          int Idout = get_local_id(0)*(BLOCK_DIM+1)+get_local_id(1);
                                                  ^

ここにカーネルファイルがあります

新しい方 :

#define BLOCK_DIM 16

__kernel void   transpose(
             __global float2* dataout, 
             __global float2* datain, 
             int width, int height)

// width = N (signal length) 
// height = batch_size (number of signals in a batch)

{
// read the matrix tile into shared memory

__local float2 block[BLOCK_DIM * (BLOCK_DIM + 1)] ;
   unsigned int xIndex = get_global_id(0);
   unsigned int yIndex = get_global_id(1);

    if((xIndex < width) && (yIndex < height))
    {
            unsigned int index_in = yIndex * width + xIndex;
                       int Idin = get_local_id(1)*(BLOCK_DIM+1)+get_local_id(0);
                       block[Idin]=  datain[index_in];
    }

barrier(CLK_LOCAL_MEM_FENCE);

// write the transposed matrix tile to global memory

             xIndex = get_group_id(1) * BLOCK_DIM + get_local_id(0);
             yIndex = get_group_id(0) * BLOCK_DIM + get_local_id(1);

    if((xIndex < height) && (yIndex < width))
    {
        unsigned int index_out = yIndex * height + xIndex;
        int Idout = get_local_id(0)*(BLOCK_DIM+1)+get_local_id(1);
                dataout[index_out] = block[Idout];
    }

}
4

1 に答える 1

0

あなたの #define の質問..セミコロンは必要ありません。基本的に、#define XY は、最後にセミコロンを追加すると、コンパイルされる前にコード内のすべての「X」を「Y」に置き換えます。これは、「Y」の一部になり、多くの構文エラーを作成します。#define はステートメントではありません。

実際、これは単純な説明ですが、この質問の範囲には十分です (詳細を知りたい場合は、プリプロセッサのチュートリアルとドキュメントを参照することをお勧めします)。

于 2012-12-03T13:38:04.393 に答える