How do I take poisson draws with poissrnd() using GPU resources via arrayfun?
1 view (last 30 days)
I'm following the example: https://www.mathworks.com/help/parallel-computing/examples/using-gpu-arrayfun-for-monte-carlo-simulations.html
Everything works as expected; however, I need to model a different stochastic process.
When I swap out "randn()" for "poissrnd(1)" (the argument does not matter), I get the following error:
"Error using call_test (line 89)
Variable number of inputs is not supported.
For more information see Tips.
Error in 'poissrnd' (line: 1)"
How do I modify my poisson draw to avoid this error? Is there another function I should use instead?
"poissrnd" is listed as supported, so I imagine I'm just using it incorrectly, but I haven't found a GPU-specific use case example: https://www.mathworks.com/help/stats/referencelist.html?type=function&capability=gpuarrays
I've also tried using "random('Poisson',0.1,1,1)" but then the different error:
"Character arrays are not supported.
For more information see Tips."
I don't think this is a hardware/cuda issue, but here is the result of "gpuDevice" in case it is helpful.
CUDADevice with properties:
Name: 'TITAN RTX'
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
Joss Knight on 28 Jun 2020
As you can see from the documentation, poissrnd is not a function that is support by the FUN argument of gpuArray/arrayfun. You are seeing this error because the poissrnd function is implemented in MATLAB code and so arrayfun is trying to flow through and execute the code as a sub-function. However, poissrnd uses varargin, which isn't supported by gpuArray/arrayfun's support for sub-functions.
You could try taking a copy of the poissrnd code and seeing if you can modify it to remove the limitations.