GPU, Interpn and Meshgrid
16 次查看(过去 30 天)
显示 更早的评论
Hi,
I am trying to do some interpolation on a 4 dimensional grid, taking advantage of GPU computing. However, when creating my grid with ndgrid, matlab says that only grid generated with meshgrid are valid. This is true only for the GPU version, there is no problem when I don't use a GPU array.
The problem is that meshgrid cannot be 4 dimensional (maximum is 3). Does it mean than interpn cannot be use with GPU arrays? There is probably a way to avoid this (otherwise a gpu version of interpn is imposible to use), but I cannot find it.
Advice would be welcome!
Thanks
0 个评论
回答(2 个)
Matt J
2014-8-20
编辑:Matt J
2014-8-20
I suspect you are inadvertently calling interp2, rather than interpn. interp2 does require that the data be as if produced by meshgrid. In any case, you should show the code you have run so that we can reproduce it.
Ultimately, though, there is no reason to use either ndgrid or meshgrid when working with interpn or griddedInterpolant. It consumes extra memory unnecessarily and is, I believe, purely for backward compatibility. You can just call interpn with the original 1D grid vectors used as arguments to ndgrid. This is true in the CPU version and should be true on the GPU as well.
Jill Reese
2014-8-27
If you look at the help for gpuArray/interpn in R2014a it shows an example of 4D interpolation. My theory is that your inputs to NDGRID don't satisfy some of the restrictions imposed on the grid by the GPU version of interpn, namely that:
- The grid arguments must be finite vectors or N-D arrays with increasing and non-repeating elements in corresponding dimension.
- When the grid arguments are N-D arrays, they must align with cartesian axes, as if they were produced by ndgrid.
Can you share what your inputs to ndgrid look like?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GPU Computing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!