Info

This question is closed. Reopen it to edit or answer.

regarding parfor and brange

1 view (last 30 days)
Kollipara
Kollipara on 14 Jun 2014
Closed: MATLAB Answer Bot on 20 Aug 2021
actually i am working on convolution of an 1D signal all the inputs and outputs are vectors of sizes typically (1,15million) and conv is predefined function in matlab and gaussian filter is an 1d gaussian signal of length (1,100). my code is something like this
for i=1:20
a=conv(input_signal_1,gaussian_filter,'same')
b=conv(input_signal_2,gaussian_filter,'same')
c=conv(input_signal_1.*cos(2i-10),gaussian_filter,'same')
d=conv(input_signal_2.*sin(2i-10),gaussian_filter,'same')
output_1=output_1+(cos(2i-10).*c +sin(2i-10).*d)
end
the time taken for the above task is about 20 seconds with parfor its becoming even more worst even after creating a pool of 4 workers its actually taking 200 seconds with drange time is around 19 seconds actually i want to decrease the time to around 5 seconds how can i do it with parallel computation toolbox my pc is an quadcore i7 2.2 Ghz and has 8gb of ram have matlab 2012b
  2 Comments
Matt J
Matt J on 14 Jun 2014
You don't use the loop variable i anywhere in your example code, so it's hard to see what's supposed to be i-dependent. Is cos(2i-10) supposed to be cos(2*i-10)?
We also can't see what inputs get created on the client and what gets created inside the loop.
Kollipara
Kollipara on 15 Jun 2014
Mr Matt cos term is i dependent its cos(2*i -10) and similarly for sine .Sir i am actually i am new to parallel computation tool box i saw some function like parfor, drange, pmode, spmd, i was not able to understand them and when i applied them to the above code parfor took 10 times more than then the time taken by serial for loop . and drange and serial for loop gave almost the same times so which function am i supposed to use to bring down the time by 4 times(ie 5 seconds)
inputs are typically one dimensional vectors of length 15 million i found out that conv was the fastest among convn and imfilter
thanking you

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!