OS X上的ViennaCL:无法将数据复制到GPU

时间:2013-05-14 14:26:01

标签: opencl viennacl

我正在学习与ViennaCL合作。第一次尝试CPU工作正常,现在我正在尝试使用OpenCL。但是,我无法将数据传输到GPU上 - 虽然矩阵似乎已创建,但它们没有得到任何内容:

#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));
}

在此之后,data_gpu(0,0)0,但我认为它应为1

我正在使用g++ nocopy.cpp -framework OpenCL进行编译。我正在使用OS X和提供的OpenCL驱动程序。

我在这里做错了什么?

编辑:删除VIENNACL_WITH_OPENCL可解决问题,但不是我想要的。

1 个答案:

答案 0 :(得分:0)

看起来(我?)OpenCL的OS X安装在某种程度上被打破了。其他简单的OpenCL示例也失败了:

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