octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

permute optimization


From: Jaroslav Hajek
Subject: permute optimization
Date: Tue, 16 Dec 2008 10:48:20 +0100

hi all,

using a similar technique as for dense indexing, I've rewritten
permute, using a recursive, possibly parallelizable algorithm.
As usual, a simplistic benchmark follows (set n to suitable value):
n = 80;
a = ones (n, 2*n, 2*n, 2, 5);
tic; b = permute (a, [1, 2, 3, 5, 4]); toc
clear b
tic; b = permute (a, [3, 4, 1, 2, 5]); toc
clear b
tic; b = permute (a, [4, 3, 1, 2, 5]); toc


before patch:

Elapsed time is 0.202561 seconds.
Elapsed time is 0.290111 seconds.
Elapsed time is 1.05752 seconds.

after:

Elapsed time is 0.10301 seconds.
Elapsed time is 0.212579 seconds.
Elapsed time is 0.299735 seconds.

I.e. speed-up by 96.6%, 36.5%, 252.8% (measured as old time / new time - 1).

there is a further optimization possible - a blocked generalized
transpose analogous to David's transpose optimization. Given the
relative importance of transpose vs. permute, I don't think it's
necessary, but certainly possible.

regards

-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]