尝试在NVIDIA SDK模板中将OpenCL与CUDA混合使用 [英] Trying to mix in OpenCL with CUDA in NVIDIA's SDK template

查看:302
本文介绍了尝试在NVIDIA SDK模板中将OpenCL与CUDA混合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在艰难地建立一个实验,在该实验中,我在设备上使用CUDA分配内存,将指针指向设备上的内存,在OpenCL中使用它,然后返回结果.我想看看是否有可能.我很难让CUDA项目工作,所以我只是在他们的SDK中使用了Nvidia的模板项目.在生成文件中,我在common.mk的libs部分中添加了-lOpenCL.当我这样做时一切都很好,但是当我在template.cu中添加#include <CL/cl.h>以便可以开始进行OpenCL调用时,我遇到了100多个错误.它们看起来都与此相似,但是最后的函数名称不同:

I have been having a tough time setting up an experiment where I allocate memory with CUDA on the device, take that pointer to memory on the device, use it in OpenCL, and return the results. I want to see if this is possible. I had a tough time getting a CUDA project to work so I just used Nvidia's template project in their SDK. In the makefile I added -lOpenCL to the libs section of the common.mk. Everything is fine when I do that, but when I add #include <CL/cl.h> to template.cu so I can start making OpenCL calls, I get over a 100 errors. They all look similar to this, but with different function names at the end:

/usr/lib/gcc/x86_64-linux-gnu/4.4.1/include/xmmintrin.h(334):错误: 标识符"__builtin_ia32_cmpeqps"未定义

/usr/lib/gcc/x86_64-linux-gnu/4.4.1/include/xmmintrin.h(334): error: identifier "__builtin_ia32_cmpeqps" is undefined

我很难找出原因.如果可以的话请帮忙.另外,如果有一种更简单的方法来设置项目,该项目将能够调用CUDA和OpenCL API,请告诉我.

I am having a hard time figuring out why. Please help if you can. Also, if there is an easier way to set up a project that'll be able to call the CUDA and OpenCL APIs let me know.

推荐答案

我还没有真正使用cuda,所以我不知道我的答案有多有用.

I haven't really worked with cuda, so I don't know how helpful my answer is.

据我了解,您正在尝试直接从cuda主机代码中使用opencl,如果我记得使用nvidia的某些编译器而不是标准gcc正确地进行了编译,则为.因此,问题可能在于该编译器未实现与上述标头一起使用所必需的内置函数. 在这里寻找类似的问题及其解决方案: http://forums.nvidia.com/lofiversion/index.php?t88573.html

From what I understand you are trying to use opencl directly from your cuda hostcode, which is if I remember correctly compiled using some compiler from nvidia instead the standard gcc. So the problem is probably that this compiler doesn't implement the necessary builtins to work with the mentioned headers. Look here for a similar problem and it's solution: http://forums.nvidia.com/lofiversion/index.php?t88573.html

似乎您必须将需要opencl api的所有内容都放入一个不同的(非cuda)编译单元中,以便它可以由非nvidia编译器进行编译.

It seems you have to put everything which needs the opencl api into a different (non cuda) compilation unit so that it will be compiled by the non nvidia compiler.

但是,我不会指望这种工作方式(因为opencl缓冲区不仅是指向内存的指针,而且还应包含一些元信息),仅仅是因为没有真正的理由应该工作,并且如果不能保证它继续这样做.

However I wouldn't count on this working (since opencl buffers aren't just pointers to the memory but should contain some metainformations to), simply because there is no real reason it should work and if it does there is no guarantee that it continues to do so.

如果您真的想尝试使用opengl进行互操作,则因为opencl和cuda都具有允许从opengl缓冲区创建缓冲区的扩展.

What you could try if you really want to is using opengl for the interop, since both opencl and cuda have extensions to allow creating buffers from opengl buffers.

但是为什么您需要这样做?是什么使您无法在短期内使用Apple的实现,因为IIRC是开放源代码,并且大多数(opencl部件)无论如何都应独立于平台.

However why do you need to do this? Whats keeping you from using Apple's implementation shortterm, since IIRC it's open source and most of it (the opencl parts) should be platform independent anyways.

这篇关于尝试在NVIDIA SDK模板中将OpenCL与CUDA混合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆