I'm just learning to work with ViennaCL. The first tries on the CPU worked fine, now I am trying to use OpenCL. However, I can't manage to get data onto the GPU - while the matrices seem to be created, they don't get any contents:
#define VIENNACL_WITH_OPENCL
#define VIENNACL_WITH_UBLAS
#include <boost/numeric/ublas/matrix.hpp>
#include "viennacl/matrix.hpp"
int main() {
boost::numeric::ublas::matrix<float> data_cpu(1,1);
data_cpu(0,0) = 1;
viennacl::matrix<float> data_gpu(1,1);
viennacl::copy(data_cpu, data_gpu);
assert(data_cpu(0,0) == data_gpu(0,0));
}
After this, data_gpu(0,0)
is 0
but I believe it should be 1
.
I'm compiling this with g++ nocopy.cpp -framework OpenCL
. I am using OS X with the provided OpenCL driver.
What am I doing wrong here?
Edit: Removing VIENNACL_WITH_OPENCL
fixes the problem, but is not what I want.
Looks like (my?) OS X installation of OpenCL is somehow broken. Other, plain, OpenCL examples fail as well:
noname:histogram Markus$ ./histogram
OpenCL Device Vendor = NVIDIA, OpenCL Device Name = GeForce GT 650M, OpenCL Device Version = OpenCL 1.1
Image Histogram for image type = CL_RGBA, CL_UNORM_INT8: verify_histogram_results failed for indx = 0, gpu result = 0, expected result = 8204
Image dimensions: 1920 x 1080 pixels, Image type = CL_RGBA, CL_UNORM_INT8
Time to compute histogram = 0 ms
Image Histogram for image type = CL_RGBA, CL_FLOAT: verify_histogram_results failed for indx = 0, gpu result = 0, expected result = 8049
Image dimensions: 1920 x 1080 pixels, Image type = CL_RGBA, CL_FLOAT
Time to compute histogram = 0 ms
noname:histogram Markus$ pwd
/Users/Markus/Desktop/tmp/opencl-book-samples-read-only/src/Chapter_14/histogram