Hey there,
when I’m using CUDA in a C-mexfile in matlab, do you know by chance what happens when I call the function ‘mexCallMATLAB’ to execute a built-in matlab function (e.g. ‘feval’ to evaluate a function handle with certain parameters)? Will this be executed on the GPU or (what I think) on the CPU?
thanks
It will be executed on CPU. You also need to move the data into matlab before running it.
But it can be very useful, I have a program that runs on the GPU, and calculates a matrix, then I need to invert a matrix, so I do that with mexCallMatlab, then move the inverted matrix back to GPU, and do some more heavy calculations.
It turned out that the matrix inversion (in single precision) is really insignificant in the total computation time.
Thanks so far. In my case, it will matter because the purpose of my program is to evaluate a matlab function handle (passed by the user to my mex-program) at many many different points which I try to do by calling matlabs built-in-function feval via mexCallMATLAB. But as you stated above, mexCallMATLAB will than be executed on my CPU so that the sense of my program is gone :(
Probably I have to look for another solution to evaluate a mathematical function passed as argument to my mex-program directly on the GPU (probably without feval, but with some C-librarys or something like that).
You can use Jacket from AccelerEyes for this.
Would this support evaluating a function handle from within a mex-file on the GPU? What function do I have to look for?