Filter löschen
Filter löschen

Pass a Matlab Function handle to mex file in GPU computing

2 Ansichten (letzte 30 Tage)
Qun Wu
Qun Wu am 6 Sep. 2017
Bearbeitet: Walter Roberson am 20 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)

Antworten (1)

Joss Knight
Joss Knight am 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 Kommentar
Qun Wu
Qun Wu am 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu GPU Computing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by