Effacer les filtres
Effacer les filtres

Pass a Matlab Function handle to mex file in GPU computing

2 vues (au cours des 30 derniers jours)
Qun Wu
Qun Wu le 6 Sep 2017
I am trying to pass a Matlab function(.m file) which is for the math operation only to one mex file. the mex file is for GPU computing including one _global_ type function and several _device_ type functions. I want to pass the .m file to one of the device functions for calculations.
Following some posters online, I find the method that is able to integrate C++ shared library. http://www.mathworks.com/help/compiler_sdk/cxx/c-shared-library-target-1.html?#responsive_offcanvas
However, it seems that the method can only pass the function to mex instead of to _device_ type function in mex file. I got some errors when calling the generated .dll from _device_ type function since the method is using mwArray class which is including some host functions. And we can not call host function from device function. Can you please give me any suggestions? Thank you.
Qun
(newie to GPU)

Réponses (1)

Joss Knight
Joss Knight le 9 Sep 2017
Hi Qun. What you appear to be trying to do is have a GPU run a MATLAB function. This, I'm afraid, is impossible. MATLAB is running on the host. Only the host can issue eval commands to MATLAB.
If you can be more specific about what you're trying to do then perhaps we can come up with a solution that doesn't require you to rewrite your MATLAB function in CUDA C++. For instance, you may find you can use gpuArray/arrayfun to execute your code, with no need to use MEX at all.
  1 commentaire
Qun Wu
Qun Wu le 19 Sep 2017
I am making a Matlab GUI where the user can input the ODE model of a system and some related parameters. And then it shows the result of some control algorithm. I need the model to do some calculations in GPU device. So I try to find a way to pass the model to GPU. Thank you.

Connectez-vous pour commenter.

Catégories

En savoir plus sur GPU Computing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by