简体   繁体   English

如何在C ++中的另一个mex(MATLAB)目标文件中调用一个cuda目标文件的函数?

[英]How do I call one cuda object file's function inside other mex (MATLAB) object file in c++?

I am writing mex code and the cuda code. 我正在编写mex代码和cuda代码。 I am wonder about having two object files of each code and calling cuda kernel from mex file as I am getting an executable by combination of their object files. 我想知道每个代码都有两个目标文件,并从mex文件调用cuda内核,因为我通过结合它们的目标文件来获得可执行文件。 Therefore I need to know that (if it is possible) how could I call one object file's function from other object file. 因此,我需要知道(如果可能)如何从另一个目标文件调用一个目标文件的功能。 Does it working to compile mex and cuda with their separate compilers and combine them in that way? 是否可以使用各自的编译器编译mex和cuda并以这种方式组合它们?

It's completely possible. 这是完全可能的。 I played with this a while back. 我前一段时间玩过这个。 The currently supported ways to do this use the MATLAB parallel computing toolbox. 当前支持的方法使用MATLAB并行计算工具箱。 There are instructions to do so here . 有指示,所以做

To expand a little bit, compiled mex files are really just dynamic libraries with a compiled mex gateway. 为了扩展一点,已编译的mex文件实际上只是具有已编译的mex网关的动态库。 So long as you have the gateway, appropriately link your files, and give the appropriate mex extension to the resulting compiled file (like mexa64, mexmaci64, etc.) the file will work. 只要您具有网关,就可以适当地链接文件,并为生成的编译文件提供适当的mex扩展名(例如mexa64,mexmaci64等),该文件将起作用。

It's important to note, you need not use the mex function from within MATLAB to compile your file. 重要的是要注意,您无需使用MATLAB中的mex函数来编译文件。 This allows for some unsupported ways in which you can compile outside of MATLAB. 这允许您使用一些不受支持的方式在MATLAB之外进行编译。 This might be useful if you don't have the parallel toolbox, if you need more subtle control over what's going on, or prefer to use make in your workflow. 如果您没有并行工具箱,或者需要对操作进行更细微的控制,或者更喜欢在工作流程中使用make,那么这可能会很有用。 The instructions for how to get started with this are here . 有关如何开始此操作的说明,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从MATLAB mex函数播种并调用C ++随机数生成器? - How can I seed and call C++ random number generator from MATLAB mex function? 如何通过将类的对象和成员函数传递给C ++中的另一个函数来调用类? - How do I call a class by passing it's object and member function to another function in c++? 如何从Java调用C ++目标文件中的函数? - How to call a function in a c++ object file from java? How do I call a member function inside a non-member function in C++ with an object created outside the non-member function? - How do I call a member function inside a non-member function in C++ with an object created outside the non-member function? 如何使用C链接制作CUDA目标文件? - How to make CUDA object file with C linkage? 如何从C ++调用matlab成员函数? - How do I call matlab member function from C++? 将值从C ++ MEX文件返回到MATLAB - Return values from a C++ MEX file to MATLAB 如何在MATLAB的mex c ++函数中循环遍历矩阵元素? - How to loop through matrix elements in mex c++ function for MATLAB? 在C ++共享对象文件中找到完整的函数定义 - Find the complete function definition inside C++ shared object file 如何从C / C ++中止MATLAB m文件功能? - How do I abort a MATLAB m-file function from C/C++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM