Reputation: 51
I am trying to implement a convolution along one dimension of a large N-D array in parallel in Matlab. The convolution filter is small enough that it doesn't make sense to use an FFT to do it. For very long 1D signals, I know I can call conv(gpuArrayA,gpuArrayB)
, and for many functions I can use bsxfun
to apply a function in parallel across a single dimension of a gpuArray, however when I try
bsxfun(@conv,gpuArrayA,gpuArrayB)
I get the error
Error using gpuArray/bsxfun
Use of 'conv' is not supported.
So then is there a way to implement this in Matlab without having to write custom CUDA code?
Upvotes: 1
Views: 451
Reputation: 1137
Couldn't you just call convn() with a 1D convolution kernel, e.g.,
A=gpuArray(rand(100,100,100));
kernel=gpuArray([1;1;1]);
result = convn(A,kernel,'same'); % convolution along dim=1
I find I get faster results with this than an equivalent CPU version, so there must be some GPU parallelization built into this.
Upvotes: 1