Re: very slow vectorized code



"Julian Reichl" <julesreichl@xxxxxxxxxxx> wrote in message
<fupbim$hs6$1@xxxxxxxxxxxxxxxxxx>...
I just tried commenting out all the other code within the
loop
i=1:28305
...
end
and it bought that e(:,:)=0;
statement back to 0.04s. So could this mean that there is
some memory issue?

"Julian Reichl" <julesreichl@xxxxxxxxxxx> wrote in message
<fupais$8av$1@xxxxxxxxxxxxxxxxxx>...
Hi all,
I have a problem that I can't figure out. I have two
versions of some code, one vectorised, the other not.
The
vectorised version runs WAY slower for single repeats -
~17
seconds cf. 0.3 seconds.

The profiler tells me that pretty much every line of the
code is a lot slower in the vectorised version. Even
simple
things like

e=repmat(1,1);
for i=1:28305
e(:,:)=0;
end

(the 1:28305 is a time-stepping loop and can't be
removed)
takes 0.39 s inside the vectorised code (not including
the
repmat), whereas in the command line it takes less than
a
10th of that time.
if, in the same code (the vectorised version), I
replace it
with

for i=1:28305
e=0;
end

(which is fine for this example because it's a 1x1, but
not
for my application), the time for that function drops,
again, to ~ a 10th.

I really hope someone has an idea!!!

thanks

Julian



I guess this is because JIT accelerator, i.e. your
vectorized code is quite complicated, hence the JIT
accelerator is not able to accelerate it, while your simple
loop version is in favour for the JIT to accelerate. When
you remove all other lines in the loop, the vectorized
version becomes simple as well, hence the JIT can
accelerate it now. That is why you see speed improvement.
To demonstrate this, you can try run your code with JIT on
and off by using the command:

feature accel on

or

feature accel off

to see if this is the case.

hth
Yi Cao

.



Relevant Pages

  • Re: very slow vectorized code
    ... I'll check out the JIT thing and let you know how I go, ... loop version is in favour for the JIT to accelerate. ... feature accel off ...
    (comp.soft-sys.matlab)
  • Re: jit acceleration doesnt show up in profiler
    ... Clicking on the x shows why that line did not accelerate. ... "We recommend not writing specifically for the JIT since the JIT is ... Support and/or post it to the newsgroup. ... enhancement request into the enhancement database to investigate how to make ...
    (comp.soft-sys.matlab)
  • Re: jit acceleration doesnt show up in profiler
    ... Clicking on the x shows why that line did not accelerate. ... Hi Juliette, I've enabled the JIT column in the profile using the SETPREF command, however on OSX 10.6.4 running R2010b the profiler column title is actually 'unjitted' and the X isn't an active link and it won't let me click to see why the line was unaccelerated. ... Support and/or post it to the newsgroup. ... enhancement request into the enhancement database to investigate how to make ...
    (comp.soft-sys.matlab)
  • Re: MATLAB Programming Contest: May 9 - May 16, 20
    ... I found a timing improvement in subsol and subsoltweak, ... All these are due to JIT acceleration. ... hence it is a simple loop for JIT to accelerate. ... vectorization played a central role in this contest ...
    (comp.soft-sys.matlab)
  • Re: MATLAB Programming Contest: May 9 - May 16, 20
    ... All these are due to JIT acceleration. ... hence it is a simple loop for JIT to accelerate. ... on the contest website: ...
    (comp.soft-sys.matlab)