Questions tagged [parfor]

parfor is a Matlab command for executing the iterations of a for-loop in parallel

parfor is a MATLAB command for executing the iterations of a for-loop in parallel via a parallel pool of workers. The command is part of the Parallel Computing Toolbox of .

For more information, see the official documentation of this command.

386 questions
19
votes
2 answers

Saving time and memory using parfor?

Consider prova.mat in MATLAB obtained in the following way for w=1:100 for p=1:9 A{p}=randn(100,1); end baseA_.A=A; eval(['baseA.A' num2str(w) '= baseA_;']) end save(sprintf('prova.mat'),'-v7.3', 'baseA') To have an…
TEX
  • 2,249
  • 20
  • 43
17
votes
3 answers

MATLAB parfor is slower than for -- what is wrong?

the code I'm dealing with has loops like the following: bistar = zeros(numdims,numcases); parfor hh=1:nt bistar = bistar + A(:,:,hh)*data(:,:,hh+1)' ; end for small nt (10). After timing it, it is actually 100 times slower than using…
Junier
  • 1,622
  • 1
  • 15
  • 21
16
votes
4 answers

Matlab: Print progress from parfor loop

I run a lot of long simulations in Matlab, typically taking from a couple of minutes to a couple of hours, so to speed things up I decided to run the simulations simultaneously using a parfor loop. arglist = [arg1, arg2, arg3, arg4]; parfor ii =…
martin-bjork
  • 163
  • 1
  • 2
  • 8
11
votes
3 answers

Prevent MATLAB from opening pool

When I have the parallel computing toolbox installed and use parfor in my code, MATLAB starts the pool automatically once it reaches the parfor loop. This however makes it difficult to debug at times, which is why I would like to prevent MATLAB from…
user1809923
  • 1,235
  • 3
  • 12
  • 27
10
votes
1 answer

How to set the max number of workers in parpool/matlabpool from console?

I know how to change the maximum number of workers using the Parallel preferences window in Matlab, but I cannot find any documentation about how to make changes on the preferences from console/code, and specifically about how to change the maximum…
Luis Felipe
  • 103
  • 1
  • 1
  • 4
10
votes
3 answers

Can a Matlab PARFOR loop be programmatically switched on/off?

Have a simple question about parfor in MATLAB. I would like to set a flag in my program to change between parfor and regular for loops. Basically, I need this functionality so that some parts of my code can update graphics in a "debug" mode, then…
Kyle Lynch
  • 235
  • 1
  • 3
  • 6
9
votes
2 answers

Bad version or endian-key in MATLAB parfor?

I am doing parallel computations with MATALB parfor. The code structure looks pretty much like %%% assess fitness %%% % save communication overheads bitmaps = pop(1, new_indi_idices); porosities = pop(2, new_indi_idices); mid_fitnesses = zeros(1,…
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
9
votes
3 answers

How to nest multiple parfor loops

parfor is a convenient way to distribute independent iterations of intensive computations among several "workers". One meaningful restriction is that parfor-loops cannot be nested, and invariably, that is the answer to similar questions like there…
s.bandara
  • 5,636
  • 1
  • 21
  • 36
9
votes
3 answers

Matlab parfor loop indexing

Does anybody know what's going on in this simple code using parfor in matlab? Thanks, I sliced a matrix into four arrays and want to update elements in each array independently Here is a simple version: a = zeros(4,4); parfor i = 1:4 j = 2;…
Zongyi Gong
  • 91
  • 1
  • 4
8
votes
2 answers

MATLAB parfor slicing issue?

I have a section of code that finds Harris corners in a sequence of images. I need to do this for 92 images, but it's rather slow. As such, I'd like to run the code in parallel. The code I have below has an error related to the variable…
Bradley Powers
  • 717
  • 7
  • 19
8
votes
3 answers

Sending data to workers

I am trying to create a piece of parallel code to speed up the processing of a very large (couple of hundred million rows) array. In order to parallelise this, I chopped my data into 8 (my number of cores) pieces and tried sending each worker 1…
Adriaan
  • 17,741
  • 7
  • 42
  • 75
8
votes
1 answer

Why is batch mode so much faster than parfor?

I am writing matlab code to perform a 3 dimensional integral: function [ fint ] = int3d_ser(R0, Rf, N) Nr = N; Nt = round(pi*N); Np = round(2*pi*N); rs = linspace(R0, Rf, Nr); ts = linspace(0, pi, Nt); ps = linspace(0, 2*pi, Np); dr =…
drjrm3
  • 4,474
  • 10
  • 53
  • 91
8
votes
2 answers

How to parallel 4 works with PARFOR with a Core i3 in Matlab

I have Matlab R2012b for Ubuntu 64 bits. I have a Intel Core i3 CPU M 330 @ 2.13GHz × 4. I want to use parfor to parallelize 4 loops at same time. Because Intel Core i3 has 2 Cores and 4 Threads I use this code: if matlabpool('size') == 0 % checking…
6
votes
2 answers

globals and parfor

Inside a parfor loop, I am trying to call a function that accesses a global to no avail. The function function a = getA() global OPTIONS; a=OPTIONS.PROBLEM.A; end The loop: parfor i=1:3 b=getA(); end The error: Error using…
olamundo
  • 23,991
  • 34
  • 108
  • 149
5
votes
1 answer

work stealing with Parallel Computing Toolbox

I have implemented a combinatorial search algorithm (for comparison to a more efficient optimization technique) and tried to improve its runtime with parfor. Unfortunately, the work assignments appear to be very badly unbalanced. Each subitem i has…
Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
1
2 3
25 26