問題は解決しました (興味がある場合は、行の下の 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];
}
}