indata:
0,000000 1,000000 2,000000 3,000000
1,000000 2,000000 3,000000 4,000000
2,000000 3,000000 4,000000 5,000000
3,000000 4,000000 5,000000 6,000000
outdata:
0,000000 1,000000 2,000000 3,000000
1,000000 2,000000 3,000000 4,000000
0,000000 0,000000 0,000000 0,000000
0,000000 0,000000 0,000000 0,000000
indata:
0,000000 1,000000 2,000000 3,000000
1,000000 2,000000 3,000000 4,000000
2,000000 3,000000 4,000000 5,000000
3,000000 4,000000 5,000000 6,000000
outdata:
0,000000 1,000000 2,000000 3,000000
1,000000 2,000000 3,000000 4,000000
0,000000 0,000000 0,000000 0,000000
0,000000 0,000000 0,000000 0,000000
To copy to clipboard, switch view to plain text mode
So does it mean that QtOpenCL does not support doubles? It seems that it is not possible to setArg a double.
QCLContext CLcontext;
if (!CLcontext.create()) {
this->Warning("Could not create OpenCL context for the GPU\n");
qApp->quit();
}
QCLVector<double> inbuffer = CLcontext.createVector<double>(kernel_size.width()*kernel_size.height(), QCLMemoryObject::ReadOnly);
QCLVector<double> outbuffer = CLcontext.createVector<double>(kernel_size.width()*kernel_size.height(), QCLMemoryObject::WriteOnly);
int idx=0;
for (int i=0 ; i<kernel_size.width() ; i++)
for (int j=0 ; j<kernel_size.height() ; j++,idx++)
inbuffer[idx] = (double)(i + j);
QCLProgram CLprogram = CLcontext.buildProgramFromSourceFile("./program.cl");
QCLKernel CLkernel = CLprogram.createKernel("program");
CLkernel.setGlobalWorkSize(kernel_size.width()*kernel_size.height());
CLkernel.setArg(0, outbuffer);
CLkernel.setArg(1, inbuffer);
CLkernel.run();
int id=0;
this->Print("indata:");
for (int j=0 ; j<kernel_size.height() ; j++) {
for (int i=0 ; i<kernel_size.width() ; i++,id++)
this->Print(" %lf\r", inbuffer[id]);
this->Print(" ");
}
id=0;
this->Print("outdata:");
for (int j=0 ; j<kernel_size.height() ; j++) {
for (int i=0 ; i<kernel_size.width() ; i++,id++)
this->Print(" %lf\r", outbuffer[id]);
this->Print(" ");
}
QCLContext CLcontext;
if (!CLcontext.create()) {
this->Warning("Could not create OpenCL context for the GPU\n");
qApp->quit();
}
QCLVector<double> inbuffer = CLcontext.createVector<double>(kernel_size.width()*kernel_size.height(), QCLMemoryObject::ReadOnly);
QCLVector<double> outbuffer = CLcontext.createVector<double>(kernel_size.width()*kernel_size.height(), QCLMemoryObject::WriteOnly);
int idx=0;
for (int i=0 ; i<kernel_size.width() ; i++)
for (int j=0 ; j<kernel_size.height() ; j++,idx++)
inbuffer[idx] = (double)(i + j);
QCLProgram CLprogram = CLcontext.buildProgramFromSourceFile("./program.cl");
QCLKernel CLkernel = CLprogram.createKernel("program");
CLkernel.setGlobalWorkSize(kernel_size.width()*kernel_size.height());
CLkernel.setArg(0, outbuffer);
CLkernel.setArg(1, inbuffer);
CLkernel.run();
int id=0;
this->Print("indata:");
for (int j=0 ; j<kernel_size.height() ; j++) {
for (int i=0 ; i<kernel_size.width() ; i++,id++)
this->Print(" %lf\r", inbuffer[id]);
this->Print(" ");
}
id=0;
this->Print("outdata:");
for (int j=0 ; j<kernel_size.height() ; j++) {
for (int i=0 ; i<kernel_size.width() ; i++,id++)
this->Print(" %lf\r", outbuffer[id]);
this->Print(" ");
}
To copy to clipboard, switch view to plain text mode
Bookmarks