Cuda 中的 CImg 库
我正在 VS2008、Win 7 上的 CUDA C 中编写代码。我得到了一个要显示为图像的浮点数矩阵..我将其保存为 .bin 文件并将其加载到一个单独的 .cpp 文件中并成功形成了使用 CImg 库的图像...但是,当我尝试将类似的代码添加到 .cu 文件时,它会在编译时给出一个奇怪的错误,如下所示...
error: identifier "_ZN12cimg_library4cimg9superset2IfffE4typeE" is undefined
我尝试在 .cu 文件中添加的代码片段
#include <CImg.h>
using namespace cimg_library;
....host code.....continues...
CImg<float> img1(448,448);
for (int nn=0;nn<200704;nn++)
img1[nn] = dR[nn]; // dR is obtained after cudamemcpy DtoH
img1.display();
在论坛 i 下给出找不到对此以及将 CImg 与 Cuda 一起使用有很多帮助.. 有什么方法可以将 CImg 与 cuda 一起使用..
谢谢
I am working on a code in CUDA C on VS2008 ,Win 7. I got a matrix of float which is to be displayed as image ..i saved it as .bin file and load it in a separate .cpp file and successfully formed the image using CImg library...however when i try to add the similar code to .cu file it gives a strange error as shown below on compilation...
error: identifier "_ZN12cimg_library4cimg9superset2IfffE4typeE" is undefined
The code snippet i tried adding in .cu file is given as under
#include <CImg.h>
using namespace cimg_library;
....host code.....continues...
CImg<float> img1(448,448);
for (int nn=0;nn<200704;nn++)
img1[nn] = dR[nn]; // dR is obtained after cudamemcpy DtoH
img1.display();
At forums i cant find much help regarding this as well as use of CImg with Cuda..
is there any way i can use CImg with cuda..
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的建议是将使用 CImg 的代码移至 .cpp 文件。然后,.cpp 文件中的代码将调用 .cu 文件中的主机/设备代码。然后,.cu 文件中的代码将浮点数矩阵的指针或引用返回给 .cpp 文件中的代码。
Nvidia 的 nvcc 是一个编译器驱动程序。它调用 C/C++ 编译器来编译文件名为 .c 或 .cpp 的文件。但是,.cu 文件对 nvcc 具有特殊含义。它会进行一些解析以及查找内核函数和某些#pragmas。我不是专家,但我知道有一份手册的副本。 这里是旧版手册的链接< /a>.
My suggestion is to move the code that uses CImg to a .cpp file. The code in the .cpp file would then invoke the host/device code in the .cu file. The code in the .cu file then returns a pointer or reference to the matrix of floats back to the code in the .cpp file.
Nvidia's nvcc is a compiler driver. It invokes a C/C++ compiler to compile files with a .c or .cpp file name. However, a .cu file has special meaning to nvcc. It does some parsing and what-not to look for kernel functions and certain #pragmas. I'm not an expert, but I know there is a copy a manual floating around. Here is a link to an older copy of the manual.