1

単純な配列宣言と初期化を備えたカーネルと、問題を示すために変更した追加の関数「get_smooth_vertex(...)」があります。

//More const __constant declarations
const __constant int edge_parents[12][2] = {    {0,1},  {0,2},  {1,3},  {2,3},  {0,4},  {1,5},  {2,6},  {3,7},  {4,5},  {4,6},  {5,7},  {6,7} };
//More Functions
float3 get_smooth_vertex(const int edge_index, const float* cube_potentials) {
    int i1 = edge_parents[edge_index][0];
    int i2 = edge_parents[edge_index][1];
    if (i1==i2) return (float3)(0);\n"
    return (float3)(1);\n"
}
__kernel void march(const __global float* potentials, __global float* vertices, __global float* normals, const __constant float4* points, const int numof_points) {
    //Lots of stuff.
    //Call get_smooth_vertex(...) a few times
    //More stuff.
}

「get_smooth_vertex(...)」の if パスは常に実行されるようです! 「edge_parents」の各ペアが異なるため、これがなぜなのか想像できません。「edge_index」を確認しましたが、常に >= 0 で、常に <= 11 です。さらに、グローバル スコープまたはローカル スコープでエイリアス化された変数はありません。カーネル (およびホスト コード、FWIW) は、警告やエラーなしでコンパイルされます。

では、何が問題なのかわかりません。インデックスが互いに等しいのはなぜですか? もしかして、アライメント?Cがどのように機能するかを完全に忘れているだけですか?見てください - それはロイヤルユーザーエラーになるでしょう. . .

ありがとう、
イアン

4

1 に答える 1

2

私はあなたのコードをチェックしました、そして、比較はうまくいきます(末尾を削除した後\n")。の戻り値を評価するときに、おそらく間違いを犯しましたget_smooth_vertex()。しかし、これは、それがどのように呼び出されるかを示すコードなしではわかりません。

于 2012-07-03T15:27:44.910 に答える