Here is a simple program that works with floats, but replace float by double everywhere, including in the OpenCL code, and you get this:
Qt Code:
  1. indata:
  2. 0,000000 1,000000 2,000000 3,000000
  3. 1,000000 2,000000 3,000000 4,000000
  4. 2,000000 3,000000 4,000000 5,000000
  5. 3,000000 4,000000 5,000000 6,000000
  6. outdata:
  7. 0,000000 1,000000 2,000000 3,000000
  8. 1,000000 2,000000 3,000000 4,000000
  9. 0,000000 0,000000 0,000000 0,000000
  10. 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.
Qt Code:
  1. QCLContext CLcontext;
  2. if (!CLcontext.create()) {
  3. this->Warning("Could not create OpenCL context for the GPU\n");
  4. qApp->quit();
  5. }
  6. QCLVector<double> inbuffer = CLcontext.createVector<double>(kernel_size.width()*kernel_size.height(), QCLMemoryObject::ReadOnly);
  7. QCLVector<double> outbuffer = CLcontext.createVector<double>(kernel_size.width()*kernel_size.height(), QCLMemoryObject::WriteOnly);
  8. int idx=0;
  9. for (int i=0 ; i<kernel_size.width() ; i++)
  10. for (int j=0 ; j<kernel_size.height() ; j++,idx++)
  11. inbuffer[idx] = (double)(i + j);
  12.  
  13. QCLProgram CLprogram = CLcontext.buildProgramFromSourceFile("./program.cl");
  14. QCLKernel CLkernel = CLprogram.createKernel("program");
  15. CLkernel.setGlobalWorkSize(kernel_size.width()*kernel_size.height());
  16. CLkernel.setArg(0, outbuffer);
  17. CLkernel.setArg(1, inbuffer);
  18.  
  19. CLkernel.run();
  20.  
  21. int id=0;
  22. this->Print("indata:");
  23. for (int j=0 ; j<kernel_size.height() ; j++) {
  24. for (int i=0 ; i<kernel_size.width() ; i++,id++)
  25. this->Print(" %lf\r", inbuffer[id]);
  26. this->Print(" ");
  27. }
  28. id=0;
  29. this->Print("outdata:");
  30. for (int j=0 ; j<kernel_size.height() ; j++) {
  31. for (int i=0 ; i<kernel_size.width() ; i++,id++)
  32. this->Print(" %lf\r", outbuffer[id]);
  33. this->Print(" ");
  34. }
To copy to clipboard, switch view to plain text mode 
Qt Code:
  1. __kernel void program(__global __write_only double *output,
  2. __global __read_only double *input)
  3. {
  4. unsigned int index = get_global_id(0);
  5. output[index] = input[index];
  6. }
To copy to clipboard, switch view to plain text mode