Info

此问题已关闭。 请重新打开它进行编辑或回答。

regarding parfor and brange

2 次查看(过去 30 天)
Kollipara
Kollipara 2014-6-14
关闭: MATLAB Answer Bot 2021-8-20
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 个评论
Matt J
Matt J 2014-6-14
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 2014-6-15
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

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by