CUDA、MySQL 和 CMake
我正在尝试创建一个 CUDA 程序(我是新来的),该程序首先从远程 MySQL 数据库获取信息。在 CUDA 调用之前,我在程序内使用 MySQL 网站上的 Connector/C 库。
当使用 gcc (没有任何 CUDA 代码)时,我可以用 MySQL 编译我的程序,但不能使用 nvcc (CUDA 编译器)。一位熟悉 CUDA 的同行向我提到,他必须编译一些他正在使用 nvcc 做的 libjpg 东西,以避免“错误的架构”和链接问题。他建议我用nvcc编译Connector/C库。但是,Connector/C 库使用 CMake 而不是常规 Makefile。
因此,作为 CMake 的新手,我研究了一些东西并找到了听起来很像我需要的工具链文件(在此处找到)。但是,我在编译过程中遇到了问题,其中不包括 Connector/C 中使用的所有默认包含和库。具体来说
-- Looking for include files HAVE_ALLOCA_H
-- Looking for include files HAVE_ALLOCA_H - not found.
,
-- Looking for strstr
-- Looking for strstr - not found
这些只是几个示例,还有更多文件未找到。 我是否正确地处理这个问题?有没有我没有考虑的更明显的解决方法?如果我尝试使用 CUDA 编译 MySQL Connector/C 是正确的,是否有任何建议可以正确包含 Connector/C 所需的文件和库?
感谢您的帮助。
I'm trying to create a CUDA program (which I'm new at) that involves first grabbing information from a remote MySQL database. I'm using the Connector/C library from the MySQL website inside the program, before the CUDA calls.
I'm able to compile my program with MySQL when using gcc (without any CUDA code), but not with nvcc (the CUDA compiler). A peer who is familiar with CUDA mentioned to me that he had to compile some libjpg stuff he was doing with nvcc to avoid 'wrong architecture' and linking problems. He suggested that I compile the Connector/C library with nvcc. However, the Connector/C library uses CMake instead of a regular Makefile.
So, being new to CMake, I researched some stuff and found the toolchain file which sounded a lot like what I needed (found here). However, I am running into problems during the compile where all of the default includes and libraries used in Connector/C are not included. Specifically
-- Looking for include files HAVE_ALLOCA_H
-- Looking for include files HAVE_ALLOCA_H - not found.
and
-- Looking for strstr
-- Looking for strstr - not found
Those are just a couple examples, there are many more files that are not found.
Am I approaching this problem correctly? Is there a more obvious workaround that I am just not considering? If I am right in trying to compile MySQL Connector/C with CUDA, are there any suggestions for properly including the files and libraries required for Connector/C?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您可以将 CUDA 内核与 mysql 调用分开并将它们放在单独的文件中,则可以使用 Makefile。
我将所有 cuda 内核等保留在 .cu 文件中,然后我有一个定义:
为了便于使用,我还包含了三个函数:
然后您需要做的就是构建源文件列表并调用
:在函数
source-to-object
中有一个变量,我用它来有条件地禁用CUDA编译USE_CUDA
。If you can separate out the CUDA kernels from your mysql calls and place them in separate files, you can use your Makefile.
I keep all of the cuda kernels and such in .cu files and then I have a definition:
I've also included three functions for ease of use:
Then all you need to do is build up a list of source files and call:
Note that in the function
source-to-object
there is a variable which I use to conditionally disable CUDA compilationUSE_CUDA
.