2017-02-26 17 views
0
xx_np = np.random.rand(16500).astype(np.float32) 
u_np = np.random.rand(16500).astype(np.float32) 
vector_np = np.random.rand(16500).astype(np.float32) 
temp_np = np.random.rand(16500).astype(np.float32) 
ss_np = np.random.rand(16500).astype(np.float32) 
ctx= cl.Context([device]) #context 
queue = cl.CommandQueue(ctx) #commandqueue 
mf = cl.mem_flags #memoryflags 
xx_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=xx_np) 
u_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=u_np) 
vector_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=vector_np) 
temp_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=temp_np) 
ss_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=ss_np) 

q00=q0 
prg = cl.Program(ctx, """ 
__kernel void dota(__global float *xx, __global float *u, __global float *vector, __global float *temp,__global float *ss, __global float *res, float q00, float s,float i) 
{ 
    int index = get_global_id(0); 
    int qindex= get_global_id(0); 
    res[index] = xx[index]*u[index-1]; 
    res[index] = res[index]*u[index-1]; 
    xx[index]= xx[index]-res[index]; 
    float a= pow(pow(xx[index],2)+pow(xx[index+1],2),0.5); 
    float b= pow(pow(vector[index],2)+pow(vector[index+1],2),0.5); 
    if(b==0) 
    { i=vector[qindex]+q00; 
     b=pow(pow(i,2)+pow(i,2),0.5); 
    }  
    s=100*(a/b); 
    ss[index]=s; 
    temp[index]=ss[index]; 
} 
""").build() 
res_g = cl.Buffer(ctx, mf.WRITE_ONLY, temp_np.nbytes) 
prg.dota(queue, temp_np.shape, None, temp_g, xx_g,res_g) 
res_np = np.empty_like(temp_np) 
cl.enqueue_copy(queue, res_np, res_g) 
print res_np 

パラメータを正しく設定できません。私はカーネルコードの初心者です。 (3)とCLで生成された議論の数(9)は一致しません」と述べています。これは私が実行するときに私のコードを取得するエラーメッセージです。引数リストの長さ(3)とCL生成引数の数(9)が一致しません

答えて

1

私は、PythonでのOpenCLを使ったことがないにもかかわらず、私はtemp_g

prg.dota(queue, temp_np.shape, None, temp_g, xx_g,res_g)

  1. ... DOTA呼び出すときに十分な引数を指定していない伝えることができます
  2. xx_g
  3. res_g

dotaには非常に多くのパラメータがありますが、

+0

あなたの返事にはおめでとうございます。私は同じ問題を考え出した。しかし今は prg.dota(キュー、temp_np.shape、なし、temp_g、xx_g、ベクトル_g、u_g、ss_g、q00、s、res_g) –

+0

に変更しました。このエラーが発生しました "pyopencl.LogicError:引数#6を処理するとき(1ベース):clSetKernelArgが失敗しました:無効な引数サイズ " –

+0

提案がありますか? –

関連する問題