简体   繁体   中英

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. 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. 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?

It's completely possible. I played with this a while back. The currently supported ways to do this use the MATLAB parallel computing toolbox. 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. 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.

It's important to note, you need not use the mex function from within MATLAB to compile your file. This allows for some unsupported ways in which you can compile outside of 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. The instructions for how to get started with this are here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM