MATLAB: Debug a GPU function

debug gpu

Hi all, I have programmed a function to be executed at GPU using arrayfun call. I need to debug it but when I set breakpoints the program does not stop!!. How can I execute it step by step on GPU?.

Best Answer

The body of an arrayfun call is run on the GPU using a translation of the MATLAB code to a native form for the GPU. This gives much better performance, but does not allow debugging. Depending on your function, you might simply be able to call the function directly with gpuArray arguments, and debug that way. I.e. replace
out = arrayfun(@myFcn, in)
with
out = myFcn(in)
Obviously, this depends on whether your function can be run in vectorised form as well as element-wise form.