0

私はOpenCLプログラムを書いていますが、ビルド時に次のエラーが発生します。

Build Log:
ptxas application ptx input, line 268; error   : State space mismatch between instruction and address in instruction 'ld'
ptxas application ptx input, line 269; error   : State space mismatch between instruction and address in instruction 'ld'
ptxas application ptx input, line 270; error   : State space mismatch between instruction and address in instruction 'ld'
ptxas application ptx input, line 271; error   : State space mismatch between instruction and address in instruction 'ld'
....(same error on several more lines)

対応するptx行(自動生成)は次のとおりです。

ld.local.u32    %r1913, [demands$inst_to_cust+16];
ld.local.u32    %rl10, [demands$inst_to_cust+12];
ld.local.u32    %rl12, [demands$inst_to_cust+8];
ld.local.u32    %rl14, [demands$inst_to_cust+4];
ld.local.u32    %rl16, [demands$inst_to_cust];

これが私が書いた関数です:

int
demands(cl_ushort ball, cl_ushort bin,
    __global const struct problem *problem,
    __constant const struct demand *demand,
    const cl_ushort soln[BALL_MAXNUM],
    struct demand_op ops[DEMAND_MAXOPS],
    __global cl_ushort debug_data[DEBUG_LEN])
{
int i, k = demand->data[0]; 
int serv_to_rack[] = {0, 1, 1}; 
int inst_to_cust[] = {0, 0, 0, 1, 1}; 
int maxinst_per_rack[] = {2, 1}; 

int cust_num = inst_to_cust[ball];
int max = ball, min = ball, count = 1;
int max_in_rack = maxinst_per_rack[cust_num];
for (i = ball; i < NUM_BALLS; i++) {
    if (inst_to_cust[i] == ball) max = i;
    else break;
}

.....
}

エラーの理由は何ですか?どうすれば解決できますか?

4

1 に答える 1

1

コンパイラは、demand構造体の場所に関して混乱しています。「状態空間」は、メモリタイプのptx-talkです。ld.localソースがローカルメモリにあることを期待していますが、あなたの場合、それは実際には一定のメモリにあるように見えます。

私はOpenCLに精通していませんが、CUDAでは、__constant__修飾子は変数を定数メモリに配置します。これには、特別なキャッシュセマンティクスがあります。constC++では関係ありません。一緒に使用しているため、コンパイラが混乱している可能性があります。

__constantとの一方または両方を行constから削除してみてください__constant const struct demand *demand

于 2012-07-03T05:16:00.523 に答える